@@ -55,6 +55,10 @@ endif()
5555# add in C++ library
5656add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /../../cpp ${CMAKE_CURRENT_BINARY_DIR} /cpp EXCLUDE_FROM_ALL )
5757
58+ # a list of all "LINKED_LIBRARIES" that are given to add_pymio_module. will contain duplicates
59+ # used for wheel installation
60+ set (PYMIO_MEMILIO_LIBS_LIST)
61+
5862# Function to add a pybind11 module
5963function (add_pymio_module target_name)
6064 set (options )
@@ -66,7 +70,11 @@ function(add_pymio_module target_name)
6670 target_link_libraries (${target_name} PRIVATE ${PYBIND11_MODULE_LINKED_LIBRARIES} )
6771 target_include_directories (${target_name} PRIVATE memilio/simulation/bindings)
6872
69- # Set RPATH so extension can find the C++ libraries in lib
73+ # Collect linked libraries for later installation
74+ list (APPEND PYMIO_MEMILIO_LIBS_LIST "${PYBIND11_MODULE_LINKED_LIBRARIES} " )
75+ set (PYMIO_MEMILIO_LIBS_LIST ${PYMIO_MEMILIO_LIBS_LIST} PARENT_SCOPE)
76+
77+ # Set RPATH so extension can find the C++ libraries in lib subdirectory
7078 set_target_properties (${target_name} PROPERTIES
7179 INSTALL_RPATH "$ORIGIN/lib"
7280 )
@@ -138,28 +146,19 @@ add_pymio_module(_simulation_omseirs4
138146 SOURCES memilio/simulation/bindings/models/omseirs4.cpp
139147)
140148
141- set (MEMILIO_SIMULATION_LIBS
142- memilio
143- abm
144- ode_sir
145- ode_seir
146- ode_secir
147- ode_seirdb
148- ode_secirvvs
149- sde_sir
150- sde_sirs
151- ode_mseirs4
152- )
149+ # install all shared memilio libraries, which were given as "LINKED_LIBRARIES" to add_pymio_module
150+ list (REMOVE_DUPLICATES PYMIO_MEMILIO_LIBS_LIST)
153151
154- foreach (target_name IN LISTS MEMILIO_SIMULATION_LIBS)
152+ # Set RPATH for all C++ libraries so they can find each other
153+ foreach (target_name IN LISTS PYMIO_MEMILIO_LIBS_LIST)
155154 if (TARGET ${target_name} )
156155 set_target_properties (${target_name} PROPERTIES
157156 INSTALL_RPATH "$ORIGIN;$ORIGIN/lib"
158157 )
159158 endif ()
160159endforeach ()
161160
162- install (TARGETS ${MEMILIO_SIMULATION_LIBS }
161+ install (TARGETS ${PYMIO_MEMILIO_LIBS_LIST }
163162 LIBRARY DESTINATION lib
164163 ARCHIVE DESTINATION lib
165164 RUNTIME DESTINATION lib
0 commit comments