Skip to content
Browse files

Export targets from both the installed and build tree

  • Loading branch information...
1 parent 8013e61 commit 73134d77881ae6648a8f98daaf8630130b7f54ea @jcfr jcfr committed
Showing with 17 additions and 2 deletions.
  1. +9 −0 CMakeLists.txt
  2. +4 −1 cmake/libpython/CMakeLists.txt
  3. +4 −1 cmake/python/CMakeLists.txt
View
9 CMakeLists.txt
@@ -90,8 +90,10 @@ if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
endif(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
# Install tree directory
+set(CONFIG_INSTALL_DIR share/${LIBPYTHON})
set(INCLUDE_INSTALL_DIR include/${LIBPYTHON})
# Build tree directory
+set(CONFIG_BUILD_DIR ${CMAKE_BINARY_DIR}/${CONFIG_INSTALL_DIR})
set(INCLUDE_BUILD_DIR ${SRC_DIR}/Include)
set(BINDIR "bin") # Contains the python executable
@@ -189,6 +191,9 @@ endif(UNIX AND NOT APPLE)
set(PYTHONHOME "${LIBDIR}/${LIBPYTHON}")
set(DYNLOAD "${PYTHONHOME}/lib-dynload")
+# Clear PythonTargets.cmake
+file(WRITE ${CONFIG_BUILD_DIR}/PythonTargets.cmake "")
+
# Add extension modules
set(builtin_extensions "" CACHE INTERNAL "" FORCE)
set(builtin_source "" CACHE INTERNAL "" FORCE)
@@ -217,3 +222,7 @@ if(UNIX)
RENAME Makefile)
endif(UNIX)
+get_property(PYTHON_TARGETS GLOBAL PROPERTY PYTHON_TARGETS)
+export(TARGETS ${PYTHON_TARGETS} APPEND FILE ${CONFIG_BUILD_DIR}/PythonTargets.cmake)
+
+install(EXPORT PythonTargets FILE PythonTargets.cmake DESTINATION ${CONFIG_INSTALL_DIR})
View
5 cmake/libpython/CMakeLists.txt
@@ -222,7 +222,10 @@ function(add_libpython name type)
set_target_properties(${name} PROPERTIES COMPILE_DEFINITIONS "${builtin_definitions}")
endif(builtin_definitions)
- install(TARGETS ${name}
+ # Export target
+ set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS ${name})
+
+ install(TARGETS ${name} EXPORT PythonTargets
ARCHIVE DESTINATION ${LIBPYTHON_ARCHIVEDIR}
LIBRARY DESTINATION ${LIBPYTHON_LIBDIR}
RUNTIME DESTINATION ${LIBPYTHON_LIBDIR}
View
5 cmake/python/CMakeLists.txt
@@ -17,4 +17,7 @@ else(ENABLE_SHARED)
set_target_properties(python PROPERTIES COMPILE_DEFINITIONS Py_NO_ENABLE_SHARED)
endif(ENABLE_SHARED)
-install(TARGETS python RUNTIME DESTINATION bin)
+# Export target
+set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS python)
+
+install(TARGETS python EXPORT PythonTargets RUNTIME DESTINATION ${BINDIR} COMPONENT Runtime)

0 comments on commit 73134d7

Please sign in to comment.
Something went wrong with that request. Please try again.