Better export cling's cmake targets
This commit is contained in:
parent
b4daff130e
commit
a65caf82d7
@ -576,31 +576,4 @@ endif()
|
||||
set(CLING_ORDER_FILE "" CACHE FILEPATH
|
||||
"Order file to use when compiling cling in order to improve startup time.")
|
||||
|
||||
if (CLING_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
|
||||
CMAKE_VERSION VERSION_GREATER 3)
|
||||
# Generate a list of CMake library targets so that other CMake projects can
|
||||
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
|
||||
# the usual CMake convention seems to be ${Project}Targets.cmake.
|
||||
set(CLING_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/cling)
|
||||
set(cling_cmake_builddir "${CMAKE_BINARY_DIR}/${CLING_INSTALL_PACKAGE_DIR}")
|
||||
get_property(CLING_EXPORTS GLOBAL PROPERTY CLING_EXPORTS)
|
||||
export(TARGETS ${CLING_EXPORTS} FILE ${cling_cmake_builddir}/ClingTargets.cmake)
|
||||
|
||||
# Install a <prefix>/lib/cmake/cling/ClingConfig.cmake file so that
|
||||
# find_package(Cling) works. Install the target list with it.
|
||||
install(EXPORT ClingTargets DESTINATION ${CLING_INSTALL_PACKAGE_DIR})
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClingConfig.cmake
|
||||
DESTINATION lib${LLVM_LIBDIR_SUFFIX}/cmake/cling)
|
||||
|
||||
install(DIRECTORY tools/Jupyter/kernel DESTINATION share/cling/Jupyter)
|
||||
|
||||
|
||||
# Also copy ClingConfig.cmake to the build directory so that dependent projects
|
||||
# can build against a build directory of Cling more easily.
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClingConfig.cmake
|
||||
${CLING_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cling/ClingConfig.cmake
|
||||
COPYONLY)
|
||||
endif ()
|
||||
add_subdirectory(cmake/modules)
|
||||
|
73
cmake/modules/CMakeLists.txt
Normal file
73
cmake/modules/CMakeLists.txt
Normal file
@ -0,0 +1,73 @@
|
||||
# Generate a list of CMake library targets so that other CMake projects can
|
||||
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
|
||||
# the usual CMake convention seems to be ${Project}Targets.cmake.
|
||||
set(CLING_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/cling)
|
||||
set(cling_cmake_builddir "${CMAKE_BINARY_DIR}/${CLING_INSTALL_PACKAGE_DIR}")
|
||||
|
||||
# Keep this in sync with llvm/cmake/CMakeLists.txt!
|
||||
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
|
||||
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
||||
|
||||
get_property(CLING_EXPORTS GLOBAL PROPERTY CLING_EXPORTS)
|
||||
export(TARGETS ${CLING_EXPORTS} FILE ${cling_cmake_builddir}/ClingTargets.cmake)
|
||||
|
||||
# Generate ClingConfig.cmake for the build tree.
|
||||
set(CLING_CONFIG_CMAKE_DIR "${cling_cmake_builddir}")
|
||||
set(CLING_CONFIG_CLANG_CMAKE_DIR "${clang_cmake_builddir}")
|
||||
set(CLING_CONFIG_EXPORTS_FILE "${cling_cmake_builddir}/ClingTargets.cmake")
|
||||
set(CLING_CONFIG_INCLUDE_DIRS
|
||||
"${CLING_SOURCE_DIR}/include"
|
||||
"${CLING_BINARY_DIR}/include"
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClingConfig.cmake.in
|
||||
${cling_cmake_builddir}/ClingConfig.cmake
|
||||
@ONLY)
|
||||
set(CLING_CONFIG_CMAKE_DIR)
|
||||
set(CLING_CONFIG_LLVM_CMAKE_DIR)
|
||||
set(CLING_CONFIG_EXPORTS_FILE)
|
||||
|
||||
# Generate ClingConfig.cmake for the install tree.
|
||||
set(CLING_CONFIG_CODE "
|
||||
# Compute the installation prefix from this LLVMConfig.cmake file location.
|
||||
get_filename_component(CLING_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
|
||||
# Construct the proper number of get_filename_component(... PATH)
|
||||
# calls to compute the installation prefix.
|
||||
string(REGEX REPLACE "/" ";" _count "${CLING_INSTALL_PACKAGE_DIR}")
|
||||
foreach(p ${_count})
|
||||
set(CLING_CONFIG_CODE "${CLING_CONFIG_CODE}
|
||||
get_filename_component(CLING_INSTALL_PREFIX \"\${CLING_INSTALL_PREFIX}\" PATH)")
|
||||
endforeach(p)
|
||||
set(CLING_CONFIG_CMAKE_DIR "\${CLING_INSTALL_PREFIX}/${CLING_INSTALL_PACKAGE_DIR}")
|
||||
set(CLING_CONFIG_LLVM_CMAKE_DIR "\${CLING_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
||||
set(CLING_CONFIG_EXPORTS_FILE "\${CLING_CMAKE_DIR}/ClingTargets.cmake")
|
||||
set(CLING_CONFIG_INCLUDE_DIRS
|
||||
"\${CLING_INSTALL_PREFIX}/include"
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClingConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClingConfig.cmake
|
||||
@ONLY)
|
||||
set(CLING_CONFIG_CODE)
|
||||
set(CLING_CONFIG_CMAKE_DIR)
|
||||
set(CLING_CONFIG_EXPORTS_FILE)
|
||||
|
||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
||||
get_property(cling_has_exports GLOBAL PROPERTY CLING_HAS_EXPORTS)
|
||||
if(cling_has_exports)
|
||||
install(EXPORT ClingTargets DESTINATION ${CLING_INSTALL_PACKAGE_DIR}
|
||||
COMPONENT cling-cmake-exports)
|
||||
endif()
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClingConfig.cmake
|
||||
DESTINATION ${CLING_INSTALL_PACKAGE_DIR}
|
||||
COMPONENT cling-cmake-exports)
|
||||
|
||||
if(NOT LLVM_ENABLE_IDE)
|
||||
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
|
||||
add_custom_target(cling-cmake-exports)
|
||||
add_llvm_install_targets(install-cling-cmake-exports
|
||||
COMPONENT cling-cmake-exports)
|
||||
endif()
|
||||
endif()
|
@ -1,12 +0,0 @@
|
||||
# This file allows users to call find_package(Cling) and pick up our targets.
|
||||
|
||||
# Cling doesn't have any CMake configuration settings yet because it mostly
|
||||
# uses LLVM's. When it does, we should move this file to ClingConfig.cmake.in
|
||||
# and call configure_file() on it.
|
||||
|
||||
# Don't just use any llvm / clang: cling needs its own:
|
||||
find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_LIST_DIR}/../llvm")
|
||||
find_package(Clang REQUIRED CONFIG NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_LIST_DIR}/../clang")
|
||||
|
||||
# Provide all our library targets to users.
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ClingTargets.cmake")
|
20
cmake/modules/ClingConfig.cmake.in
Normal file
20
cmake/modules/ClingConfig.cmake.in
Normal file
@ -0,0 +1,20 @@
|
||||
# This file allows users to call find_package(Cling) and pick up our targets.
|
||||
|
||||
@CLING_CONFIG_CODE@
|
||||
|
||||
find_package(Clang REQUIRED CONFIG
|
||||
HINTS "@CLING_CONFIG_CLANG_CMAKE_DIR@")
|
||||
|
||||
set(CLING_EXPORTED_TARGETS "@CLING_EXPORTS@")
|
||||
set(CLING_CMAKE_DIR "@CLING_CONFIG_CMAKE_DIR@")
|
||||
set(CLING_INCLUDE_DIRS "@CLING_CONFIG_INCLUDE_DIRS@")
|
||||
|
||||
# Provide all our library targets to users.
|
||||
include("@CLING_CONFIG_EXPORTS_FILE@")
|
||||
|
||||
# By creating cling-tablegen-targets here, subprojects that depend on Cling's
|
||||
# tablegen-generated headers can always depend on this target whether building
|
||||
# in-tree with Cling or not.
|
||||
if(NOT TARGET cling-tablegen-targets)
|
||||
add_custom_target(cling-tablegen-targets)
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user