export the targets with a python dependency to a different config file (#7914)

* export the targets with a python dependency to a different config file

* add the forgotten file

* improve the dependency from boost components

* fix management of dependencies for RDKitPython

* fix install location for RdkitPython cmake config file

* fix finding boost components

* put libraries that depend on rdkit_py_base in the python component
This commit is contained in:
Riccardo Vianello
2025-02-19 05:53:30 +01:00
committed by greg landrum
parent 3dcb6bebd0
commit f37ce60b7d
5 changed files with 81 additions and 24 deletions

View File

@@ -1,14 +1,11 @@
if(WIN32 OR "${Py_ENABLE_SHARED}" STREQUAL "1")
rdkit_library(RDBoost Wrap.cpp
LINK_LIBRARIES RDGeneral rdkit_py_base rdkit_base)
else()
rdkit_library(RDBoost Wrap.cpp
LINK_LIBRARIES RDGeneral rdkit_base)
if("${PYTHON_LDSHARED}" STREQUAL "")
else() # fixes an apple issue
STRING(REGEX REPLACE "-bundle" "" LDSHARED ${PYTHON_LDSHARED})
set_target_properties(RDBoost PROPERTIES LINK_FLAGS ${LDSHARED})
endif()
rdkit_library(RDBoost Wrap.cpp
LINK_LIBRARIES RDGeneral rdkit_py_base)
if(NOT WIN32 AND
NOT "${Py_ENABLE_SHARED}" STREQUAL "1" AND
NOT "${PYTHON_LDSHARED}" STREQUAL "")
# fixes an apple issue
STRING(REGEX REPLACE "-bundle" "" LDSHARED ${PYTHON_LDSHARED})
set_target_properties(RDBoost PROPERTIES LINK_FLAGS ${LDSHARED})
endif()
target_compile_definitions(RDBoost PRIVATE RDKIT_RDBOOST_BUILD)

View File

@@ -24,6 +24,7 @@ else()
endif()
set(RDKit_BUILDNAME "${CMAKE_SYSTEM_NAME}|${CMAKE_SYSTEM_VERSION}|${systemAttribute}|${compilerID}|${bit3264}")
set(RDKit_EXPORTED_TARGETS rdkit-targets)
set(RDKitPython_EXPORTED_TARGETS rdkitpython-targets)
macro(rdkit_library)
@@ -33,13 +34,25 @@ macro(rdkit_library)
${ARGN})
CAR(RDKLIB_NAME ${RDKLIB_DEFAULT_ARGS})
CDR(RDKLIB_SOURCES ${RDKLIB_DEFAULT_ARGS})
# select the export and component name for the installed library
set(exportName ${RDKit_EXPORTED_TARGETS})
set(sharedLibComponent runtime)
set(staticLibComponent dev)
foreach(linkLib ${RDKLIB_LINK_LIBRARIES})
if("${linkLib}" STREQUAL "rdkit_py_base")
set(exportName ${RDKitPython_EXPORTED_TARGETS})
set(sharedLibComponent python)
set(staticLibComponent python)
break()
endif()
endforeach()
if((MSVC AND (NOT RDK_INSTALL_DLLS_MSVC)) OR (WIN32 AND RDK_INSTALL_STATIC_LIBS))
add_library(${RDKLIB_NAME} ${RDKLIB_SOURCES})
target_link_libraries(${RDKLIB_NAME} PUBLIC rdkit_base)
if(RDK_INSTALL_DEV_COMPONENT)
INSTALL(TARGETS ${RDKLIB_NAME} EXPORT ${RDKit_EXPORTED_TARGETS}
INSTALL(TARGETS ${RDKLIB_NAME} EXPORT ${exportName}
DESTINATION ${RDKit_LibDir}/${RDKLIB_DEST}
COMPONENT dev )
COMPONENT ${staticLibComponent})
endif(RDK_INSTALL_DEV_COMPONENT)
else()
# we're going to always build in shared mode since we
@@ -48,9 +61,9 @@ macro(rdkit_library)
# with g++ unless libraries are shared.
add_library(${RDKLIB_NAME} SHARED ${RDKLIB_SOURCES})
target_link_libraries(${RDKLIB_NAME} PUBLIC rdkit_base)
INSTALL(TARGETS ${RDKLIB_NAME} EXPORT ${RDKit_EXPORTED_TARGETS}
INSTALL(TARGETS ${RDKLIB_NAME} EXPORT ${exportName}
DESTINATION ${RDKit_LibDir}/${RDKLIB_DEST}
COMPONENT runtime )
COMPONENT ${sharedLibComponent})
if(RDK_INSTALL_STATIC_LIBS)
add_library(${RDKLIB_NAME}_static ${RDKLIB_SOURCES})
@@ -60,7 +73,11 @@ macro(rdkit_library)
set(skipNext FALSE)
continue()
endif()
if(TARGET "${linkLib}")
if("${linkLib}" STREQUAL "rdkit_py_base")
# rdkit_py_base is an interface target, keep it as-is
target_link_libraries(${RDKLIB_NAME}_static PUBLIC "${linkLib}")
continue()
elseif(TARGET "${linkLib}")
get_target_property(linkLib_IMPORTED "${linkLib}" IMPORTED)
if (linkLib_IMPORTED)
# linkLib is an imported target: use it as-is
@@ -97,9 +114,9 @@ macro(rdkit_library)
endforeach()
target_link_libraries(${RDKLIB_NAME}_static PUBLIC rdkit_base)
if(RDK_INSTALL_DEV_COMPONENT)
INSTALL(TARGETS ${RDKLIB_NAME}_static EXPORT ${RDKit_EXPORTED_TARGETS}
INSTALL(TARGETS ${RDKLIB_NAME}_static EXPORT ${exportName}
DESTINATION ${RDKit_LibDir}/${RDKLIB_DEST}
COMPONENT dev )
COMPONENT ${staticLibComponent})
endif(RDK_INSTALL_DEV_COMPONENT)
set_target_properties(${RDKLIB_NAME}_static PROPERTIES
OUTPUT_NAME "RDKit${RDKLIB_NAME}_static")