diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b7948402..d15f7f708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,9 @@ endif() # so we provide an option similar to BUILD_TESTING, but just for MPM. option(MPM_BUILD_TESTING "enable testing for mpm" ON) +# CMake option for building mpm as a shared library for CI +option(MPM_BUILD_LIB "enable libmpm" OFF) + # CMake Modules set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) @@ -132,10 +135,13 @@ SET(mpm_src ${mpm_SOURCE_DIR}/src/element.cc ) +if(MPM_BUILD_LIB) add_library(lmpm SHARED ${mpm_src} ${mpm_vtk}) - add_executable(mpm ${mpm_SOURCE_DIR}/src/main.cc) target_link_libraries(mpm lmpm) +else() +add_executable(mpm ${mpm_SOURCE_DIR}/src/main.cc ${mpm_src} ${mpm_vtk}) +endif() # Unit test if(MPM_BUILD_TESTING) @@ -177,10 +183,16 @@ if(MPM_BUILD_TESTING) ${mpm_SOURCE_DIR}/tests/write_mesh_particles_unitcell.cc ${mpm_SOURCE_DIR}/tests/elements/hexahedron_gimp_element_test.cc ) - add_executable(mpmtest ${test_src}) - target_link_libraries(mpmtest lmpm) - add_test(NAME mpmtest COMMAND $) - enable_testing() + if(MPM_BUILD_LIB) + add_executable(mpmtest ${test_src}) + target_link_libraries(mpmtest lmpm) + add_test(NAME mpmtest COMMAND $) + enable_testing() + else() + add_executable(mpmtest ${test_src} ${mpm_src} ${mpm_vtk}) + add_test(NAME mpmtest COMMAND $) + enable_testing() + endif() endif() # Coverage