diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2bd85e2..646a45b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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() @@ -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 @@ -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}) + + +