Skip to content

Commit

Permalink
📝 Change CMake to toggle MPM lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
kks32 committed Nov 26, 2019
1 parent d1c90ab commit 05823df
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 $<TARGET_FILE:mpmtest>)
enable_testing()
if(MPM_BUILD_LIB)
add_executable(mpmtest ${test_src})
target_link_libraries(mpmtest lmpm)
add_test(NAME mpmtest COMMAND $<TARGET_FILE:mpmtest>)
enable_testing()
else()
add_executable(mpmtest ${test_src} ${mpm_src} ${mpm_vtk})
add_test(NAME mpmtest COMMAND $<TARGET_FILE:mpmtest>)
enable_testing()
endif()
endif()

# Coverage
Expand Down

0 comments on commit 05823df

Please sign in to comment.