Skip to content

Commit

Permalink
Rearrange order of CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
yiquintero committed Nov 23, 2023
1 parent b55184e commit 38933a0
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@ FetchContent_Declare(
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Get LAMMPS
if (TEST_IN_GITHUB_ACTIONS)
# lammps was previously downloaded and built as part of the workflow
set (LAMMPS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../lammps/src/")
else()
message(STATUS "Downloading LAMMPS")
# download lammps
FetchContent_Declare(
lammps
URL https://github.com/lammps/lammps/archive/refs/tags/stable_23Jun2022_update4.zip
)
FetchContent_Populate(lammps)
set (LAMMPS_SOURCE_DIR "${lammps_SOURCE_DIR}/src/")
endif()


#Enable testing in CMake
enable_testing()

Expand All @@ -49,9 +33,6 @@ add_executable(
testoctp.cpp
)

# Add a preprocessor definition with the path to LAMMPS
add_compile_definitions(LAMMPS_PATH=${LAMMPS_SOURCE_DIR})

# link the googletest library to the tests
target_link_libraries(
testoctp
Expand All @@ -63,29 +44,45 @@ target_link_libraries(
include(GoogleTest)
gtest_discover_tests(testoctp)


if (NOT TEST_IN_GITHUB_ACTIONS)
# copy octp files to lammps dir
file(GLOB filesToCopy "${CMAKE_SOURCE_DIR}/../src/*")
file(COPY ${filesToCopy} DESTINATION ${LAMMPS_SOURCE_DIR})
# build lammps+octp as a post-build event of the testoctp
add_custom_command(
TARGET testoctp POST_BUILD
COMMAND cd ${LAMMPS_SOURCE_DIR} &&
make yes-asphere &&
make yes-body &&
make yes-class2 &&
make yes-dipole &&
make yes-granular &&
make yes-kspace &&
make yes-manybody &&
make yes-molecule &&
make yes-rigid &&
make yes-shock &&
make -j 8 mpi
WORKING_DIRECTORY ${lammps_SOURCE_DIR}
VERBATIM
COMMENT "Build LAMMPS with OCTP plugin"
# Get LAMMPS
if (TEST_IN_GITHUB_ACTIONS)
# lammps was previously downloaded and built as part of the workflow
set (LAMMPS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../lammps/src/")
else()
message(STATUS "Downloading LAMMPS")
# download lammps
FetchContent_Declare(
lammps
URL https://github.com/lammps/lammps/archive/refs/tags/stable_23Jun2022_update4.zip
)
FetchContent_Populate(lammps)
set (LAMMPS_SOURCE_DIR "${lammps_SOURCE_DIR}/src/")
# copy octp files to lammps dir
file(GLOB filesToCopy "${CMAKE_SOURCE_DIR}/../src/*")
file(COPY ${filesToCopy} DESTINATION ${LAMMPS_SOURCE_DIR})
# build lammps+octp as a post-build event of the testoctp
add_custom_command(
TARGET testoctp POST_BUILD
COMMAND cd ${LAMMPS_SOURCE_DIR} &&
make yes-asphere &&
make yes-body &&
make yes-class2 &&
make yes-dipole &&
make yes-granular &&
make yes-kspace &&
make yes-manybody &&
make yes-molecule &&
make yes-rigid &&
make yes-shock &&
make -j 8 mpi
WORKING_DIRECTORY ${lammps_SOURCE_DIR}
VERBATIM
COMMENT "Build LAMMPS with OCTP plugin"
)
endif()

# Add a preprocessor definition with the path to LAMMPS
add_compile_definitions(LAMMPS_PATH=${LAMMPS_SOURCE_DIR})



0 comments on commit 38933a0

Please sign in to comment.