mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
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:
committed by
GitHub
parent
4eb1ea9985
commit
560d5ad604
@@ -305,8 +305,8 @@ if(RDK_BUILD_PYTHON_WRAPPERS)
|
||||
#-------
|
||||
# pull in python:
|
||||
find_package(Python3 COMPONENTS Interpreter Development.Module NumPy)
|
||||
target_include_directories(rdkit_base INTERFACE ${Python3_INCLUDE_DIRS})
|
||||
target_include_directories(rdkit_base INTERFACE ${Python3_NumPy_INCLUDE_DIRS})
|
||||
target_include_directories(rdkit_py_base INTERFACE ${Python3_INCLUDE_DIRS})
|
||||
target_include_directories(rdkit_py_base INTERFACE ${Python3_NumPy_INCLUDE_DIRS})
|
||||
|
||||
# determine linkage of python
|
||||
execute_process(
|
||||
@@ -380,7 +380,7 @@ if(RDK_BUILD_PYTHON_WRAPPERS)
|
||||
endif()
|
||||
|
||||
|
||||
install(TARGETS rdkit_py_base EXPORT ${RDKit_EXPORTED_TARGETS}
|
||||
install(TARGETS rdkit_py_base EXPORT ${RDKitPython_EXPORTED_TARGETS}
|
||||
COMPONENT dev )
|
||||
|
||||
# check to see if we can find nbval,
|
||||
@@ -604,6 +604,9 @@ if(RDK_BUILD_CONTRIB)
|
||||
endif(RDK_BUILD_CONTRIB)
|
||||
|
||||
# export the project targets (to be included in the cmake package configuration)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# first manage the targets for the base C++ toolkit
|
||||
install(
|
||||
EXPORT ${RDKit_EXPORTED_TARGETS}
|
||||
FILE ${RDKit_EXPORTED_TARGETS}.cmake
|
||||
@@ -612,7 +615,6 @@ install(
|
||||
)
|
||||
|
||||
# create and install package configuration and version files
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${RDKit_BINARY_DIR}/rdkit-config-version.cmake"
|
||||
VERSION ${RDKit_RELEASENAME}
|
||||
@@ -628,6 +630,31 @@ install(FILES
|
||||
${RDKit_BINARY_DIR}/rdkit-config-version.cmake
|
||||
DESTINATION ${RDKit_LibDir}/cmake/rdkit)
|
||||
|
||||
# then manage the targets for the python bindings
|
||||
if(RDK_BUILD_PYTHON_WRAPPERS)
|
||||
install(
|
||||
EXPORT ${RDKitPython_EXPORTED_TARGETS}
|
||||
FILE ${RDKitPython_EXPORTED_TARGETS}.cmake
|
||||
NAMESPACE RDKit::
|
||||
DESTINATION ${RDKit_LibDir}/cmake/rdkitpython
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${RDKit_BINARY_DIR}/rdkitpython-config-version.cmake"
|
||||
VERSION ${RDKit_RELEASENAME}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
configure_file (
|
||||
${RDKit_SOURCE_DIR}/rdkitpython-config.cmake.in
|
||||
${RDKit_BINARY_DIR}/rdkitpython-config.cmake @ONLY)
|
||||
|
||||
install(FILES
|
||||
${RDKit_BINARY_DIR}/rdkitpython-config.cmake
|
||||
${RDKit_BINARY_DIR}/rdkitpython-config-version.cmake
|
||||
DESTINATION ${RDKit_LibDir}/cmake/rdkitpython)
|
||||
endif(RDK_BUILD_PYTHON_WRAPPERS)
|
||||
|
||||
# Memory testing setup
|
||||
FIND_PROGRAM(MEMORYCHECK_COMMAND valgrind)
|
||||
CONFIGURE_FILE(CTestCustom.ctest.in ${RDKit_BINARY_DIR}/CTestCustom.ctest)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -24,15 +24,22 @@ set(RDKit_HAS_URF_SUPPORT @RDK_USE_URF@)
|
||||
set(RDKit_USE_OPTIMIZED_POPCNT @RDK_OPTIMIZE_POPCNT@)
|
||||
set(RDKit_USE_STRICT_ROTOR_DEFINITION @RDK_USE_STRICT_ROTOR_DEFINITION@)
|
||||
set(RDKit_USE_BOOST_VERSION @Boost_VERSION_STRING@)
|
||||
set(RDKit_USE_BOOST_SERIALIZATION @RDK_USE_BOOST_SERIALIZATION@)
|
||||
set(RDKit_USE_BOOST_COMPONENTS system)
|
||||
set(RDKit_USE_BOOST_IOSTREAMS @RDK_USE_BOOST_IOSTREAMS@)
|
||||
if (RDKit_USE_BOOST_IOSTREAMS)
|
||||
set(RDKit_USE_BOOST_COMPONENTS ${RDKit_USE_BOOST_COMPONENTS} iostreams)
|
||||
endif()
|
||||
set(RDKit_USE_BOOST_SERIALIZATION @RDK_USE_BOOST_SERIALIZATION@)
|
||||
if (RDKit_USE_BOOST_SERIALIZATION)
|
||||
set(RDKit_USE_BOOST_COMPONENTS ${RDKit_USE_BOOST_COMPONENTS} serialization)
|
||||
endif()
|
||||
|
||||
# Find the RDKit dependencies
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
find_dependency(Threads REQUIRED)
|
||||
|
||||
find_dependency(Boost @Boost_VERSION_STRING@ REQUIRED)
|
||||
find_dependency(Boost @Boost_VERSION_STRING@ COMPONENTS headers ${RDKit_USE_BOOST_COMPONENTS})
|
||||
|
||||
if(RDKit_HAS_DESCRIPTORS3D)
|
||||
find_dependency(Eigen3 REQUIRED NO_MODULE)
|
||||
|
||||
9
rdkitpython-config.cmake.in
Normal file
9
rdkitpython-config.cmake.in
Normal file
@@ -0,0 +1,9 @@
|
||||
# Find the RDKitPython dependencies
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
find_dependency(Python3 @Python3_VERSION_MAJOR@.@Python3_VERSION_MINOR@ COMPONENTS Interpreter Development.Module NumPy)
|
||||
find_dependency(Boost @Boost_VERSION_STRING@ COMPONENTS python@Python3_VERSION_MAJOR@@Python3_VERSION_MINOR@ numpy@Python3_VERSION_MAJOR@@Python3_VERSION_MINOR@)
|
||||
find_dependency(RDKit @RDKit_RELEASENAME@ REQUIRED)
|
||||
|
||||
# Import the targets
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@RDKitPython_EXPORTED_TARGETS@.cmake")
|
||||
Reference in New Issue
Block a user