76f3103a8b39da83c03aacbb8f17ecc3514af080
[alexxy/gromacs.git] / python_packaging / sample_restraint / src / cpp / CMakeLists.txt
1 # Defines targets for the C++ restraints implemented here. These CMake targets are used by the
2 # unit tests and by the Python module target defined in ../pythonmodule/CMakeLists.txt
3
4 # These targets depend both on Gromacs::libgromacs and on Gromacs::gmxapi.
5 # These dependencies are likely to evolve.
6 # In particular, Gromacs::libgromacs has been deprecated for some time.
7 # https://gitlab.com/gromacs/gromacs/-/issues?label_name%5B%5D=API+restructuring
8
9 add_library(gmxapi_extension_resources STATIC
10             sessionresources.cpp)
11 set_target_properties(gmxapi_extension_resources PROPERTIES POSITION_INDEPENDENT_CODE ON)
12 target_include_directories(gmxapi_extension_resources PUBLIC
13                            ${CMAKE_CURRENT_SOURCE_DIR})
14 target_link_libraries(gmxapi_extension_resources PUBLIC
15                       Gromacs::libgromacs
16                       Gromacs::gmxapi)
17
18 # Create an archive library for our restrained ensemble plugin.
19 add_library(gmxapi_extension_ensemblepotential STATIC
20             ensemblepotential.cpp)
21 set_target_properties(gmxapi_extension_ensemblepotential PROPERTIES POSITION_INDEPENDENT_CODE ON)
22
23 target_include_directories(gmxapi_extension_ensemblepotential PUBLIC
24                            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
25                            $<INSTALL_INTERFACE:include>
26                            )
27 # RPATH management
28 # don't skip the full RPATH for the build tree
29 set_target_properties(gmxapi_extension_ensemblepotential PROPERTIES SKIP_BUILD_RPATH FALSE)
30
31 # (but later on when installing)
32 # If building with setuptools, CMake will not be performing the install
33 set_target_properties(gmxapi_extension_ensemblepotential PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
34
35 target_link_libraries(gmxapi_extension_ensemblepotential PRIVATE
36                       gmxapi_extension_resources
37                       Gromacs::libgromacs
38                       Gromacs::gmxapi)
39
40 # Create an archive library for a test plugin.
41 add_library(gmxapi_extension_test STATIC
42             nullpotential.cpp
43             )
44 set_target_properties(gmxapi_extension_test PROPERTIES POSITION_INDEPENDENT_CODE ON)
45
46 target_include_directories(gmxapi_extension_test PUBLIC
47                            ${CMAKE_CURRENT_SOURCE_DIR}
48                            )
49 set_target_properties(gmxapi_extension_test PROPERTIES SKIP_BUILD_RPATH FALSE)
50 set_target_properties(gmxapi_extension_test PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
51 target_link_libraries(gmxapi_extension_test PRIVATE
52                       gmxapi_extension_resources)
53 target_link_libraries(gmxapi_extension_test PUBLIC
54                       Gromacs::libgromacs
55                       Gromacs::gmxapi)