Skip to content

Commit

Permalink
Synchronize changes to Colvars CMake function from GROMACS main
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Oct 7, 2024
1 parent 72a195a commit ffe753b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions gromacs/cmake/gmxManageColvars.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ function(gmx_manage_colvars)
file(GLOB COLVARS_SOURCES ${COLVARS_DIR}/*.cpp)
add_library(colvars_objlib OBJECT ${COLVARS_SOURCES})
if(GMX_LIB_MPI)
target_compile_definitions(colvars_objlib PRIVATE -DCOLVARS_MPI)
target_compile_definitions(colvars_objlib PRIVATE -DCOLVARS_MPI)
endif()
if(GMX_OPENMP)
target_compile_options(colvars_objlib PRIVATE ${OpenMP_CXX_FLAGS})
target_link_libraries(colvars_objlib PRIVATE OpenMP::OpenMP_CXX)
endif()
if(GMX_TORCH)
target_compile_options(colvars_objlib PRIVATE ${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS})
target_include_directories(colvars_objlib PRIVATE ${TORCH_INCLUDE_DIRS})
target_compile_definitions(colvars_objlib PRIVATE -DCOLVARS_TORCH)
endif()

# Set correctly the value of __cplusplus, which MSVC doesn't do by default
target_compile_options(colvars_objlib PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
# Ensure that colvars_objlib can be used in both STATIC and SHARED libraries.
Expand All @@ -58,12 +68,10 @@ function(gmx_manage_colvars)
target_sources(colvars INTERFACE $<TARGET_OBJECTS:colvars_objlib>)
target_include_directories(colvars SYSTEM INTERFACE $<BUILD_INTERFACE:${COLVARS_DIR}>)
if(GMX_LIB_MPI)
target_compile_definitions(colvars INTERFACE -DCOLVARS_MPI)
target_compile_definitions(colvars INTERFACE -DCOLVARS_MPI)
endif()

if(GMX_OPENMP)
target_compile_options(colvars_objlib PRIVATE ${OpenMP_CXX_FLAGS})
target_link_libraries(colvars_objlib PRIVATE OpenMP::OpenMP_CXX)
if(GMX_TORCH)
target_compile_definitions(colvars INTERFACE -DCOLVARS_TORCH)
endif()

set(GMX_HAVE_COLVARS 1 CACHE INTERNAL "Is colvars found?")
Expand Down

0 comments on commit ffe753b

Please sign in to comment.