2016-02-04 21:08:19 +01:00
|
|
|
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
|
2014-02-09 17:35:29 +01:00
|
|
|
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
2010-08-09 05:26:43 +02:00
|
|
|
|
2016-09-09 21:48:22 +02:00
|
|
|
# First for users who use an installed LLVM, create the LLVMExports.cmake file.
|
2016-09-09 21:45:34 +02:00
|
|
|
set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
|
2014-02-09 17:36:16 +01:00
|
|
|
get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
|
2016-09-09 21:45:34 +02:00
|
|
|
export(TARGETS ${LLVM_EXPORTS} FILE ${LLVM_EXPORTS_FILE})
|
|
|
|
|
|
|
|
# Then for users who want to link against the LLVM build tree, provide the
|
|
|
|
# normal targets and the build tree only targets.
|
|
|
|
set(LLVM_BUILDTREEONLY_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMBuildTreeOnlyTargets.cmake)
|
|
|
|
get_property(LLVM_EXPORTS_BUILDTREE_ONLY GLOBAL PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY)
|
|
|
|
export(TARGETS ${LLVM_EXPORTS_BUILDTREE_ONLY} FILE ${LLVM_BUILDTREEONLY_EXPORTS_FILE})
|
2014-02-09 17:36:16 +01:00
|
|
|
|
2014-02-21 15:17:07 +01:00
|
|
|
get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
|
2011-02-18 23:06:14 +01:00
|
|
|
|
2014-02-21 15:17:07 +01:00
|
|
|
foreach(lib ${LLVM_AVAILABLE_LIBS})
|
2011-11-29 02:31:52 +01:00
|
|
|
get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib})
|
2011-07-30 01:52:01 +02:00
|
|
|
set(all_llvm_lib_deps
|
2011-11-29 02:31:52 +01:00
|
|
|
"${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})")
|
2011-07-30 01:52:01 +02:00
|
|
|
endforeach(lib)
|
|
|
|
|
2016-10-04 19:44:28 +02:00
|
|
|
# CMake requires that all targets expressed as dependencies exist, so we can't
|
|
|
|
# have intrinsics_gen in LLVM_COMMON_DEPENDS when it is written out, otherwise
|
|
|
|
# projects building out of tree will have CMake errors. This only gets hit when
|
|
|
|
# LLVM_ENABLE_MODULES=On. Eventually we should come up with a better solution to
|
|
|
|
# this, but there is no easy solution.
|
|
|
|
if(intrinsics_gen IN_LIST LLVM_COMMON_DEPENDS)
|
|
|
|
list(REMOVE_ITEM LLVM_COMMON_DEPENDS intrinsics_gen)
|
|
|
|
endif()
|
|
|
|
|
2014-02-09 17:35:51 +01:00
|
|
|
# Generate LLVMConfig.cmake for the build tree.
|
|
|
|
set(LLVM_CONFIG_CODE "
|
|
|
|
# LLVM_BUILD_* values available only from LLVM build tree.
|
|
|
|
set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\")
|
|
|
|
set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\")
|
|
|
|
set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\")
|
|
|
|
set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\")
|
|
|
|
")
|
|
|
|
set(LLVM_CONFIG_INCLUDE_DIRS
|
|
|
|
"${LLVM_MAIN_INCLUDE_DIR}"
|
|
|
|
"${LLVM_INCLUDE_DIR}"
|
|
|
|
)
|
|
|
|
set(LLVM_CONFIG_LIBRARY_DIRS
|
|
|
|
"${LLVM_LIBRARY_DIR}"
|
|
|
|
)
|
|
|
|
set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
2016-06-22 23:01:19 +02:00
|
|
|
set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}")
|
2014-07-22 19:48:51 +02:00
|
|
|
set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
|
[CMake] Followup for r337366: Only export LLVM_LINK_LLVM_DYLIB if it's set to ON
Summary:
As it was, always exporting LLVM_LINK_LLVM_DYLIB caused out-of-tree
clients to lose the ability to link against the dylib, even if in-tree tools did
not. By only exporting the setting if it is enabled, out-of-tree clients get the
correct default, but may still choose if they can.
Reviewers: mgorny, beanz, labath, bogner, chandlerc
Reviewed By: bogner, chandlerc
Subscribers: bollu, llvm-commits
Differential Revision: https://reviews.llvm.org/D49843
llvm-svn: 338119
2018-07-27 12:57:51 +02:00
|
|
|
|
|
|
|
if (LLVM_LINK_LLVM_DYLIB)
|
|
|
|
set(LLVM_CONFIG_LINK_LLVM_DYLIB
|
|
|
|
"set(LLVM_LINK_LLVM_DYLIB ${LLVM_LINK_LLVM_DYLIB})")
|
|
|
|
endif()
|
|
|
|
|
2016-09-09 21:45:34 +02:00
|
|
|
# We need to use the full path to the LLVM Exports file to make sure we get the
|
|
|
|
# one from the build tree. This is due to our cmake files being split between
|
|
|
|
# this source dir and the binary dir in the build tree configuration and the
|
|
|
|
# LLVM_CONFIG_CMAKE_DIR being the source directory. In contrast in the install
|
|
|
|
# tree, both the generated LLVMExports.cmake file and the rest of the cmake
|
|
|
|
# source files are put in the same cmake directory.
|
|
|
|
set(LLVM_CONFIG_EXPORTS_FILE "${LLVM_EXPORTS_FILE}")
|
|
|
|
set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS};${LLVM_EXPORTS_BUILDTREE_ONLY}")
|
|
|
|
set(llvm_config_include_buildtree_only_exports
|
|
|
|
"include(\"${LLVM_BUILDTREEONLY_EXPORTS_FILE}\")")
|
2010-08-09 05:26:43 +02:00
|
|
|
configure_file(
|
2011-04-10 18:17:49 +02:00
|
|
|
LLVMConfig.cmake.in
|
|
|
|
${llvm_cmake_builddir}/LLVMConfig.cmake
|
|
|
|
@ONLY)
|
2016-09-09 21:45:34 +02:00
|
|
|
set(llvm_config_include_buildtree_only_exports)
|
2011-04-10 18:17:49 +02:00
|
|
|
|
2014-02-09 17:35:40 +01:00
|
|
|
# For compatibility with projects that include(LLVMConfig)
|
|
|
|
# via CMAKE_MODULE_PATH, place API modules next to it.
|
|
|
|
# This should be removed in the future.
|
|
|
|
file(COPY .
|
|
|
|
DESTINATION ${llvm_cmake_builddir}
|
|
|
|
FILES_MATCHING PATTERN *.cmake
|
|
|
|
PATTERN .svn EXCLUDE
|
|
|
|
PATTERN CMakeFiles EXCLUDE
|
|
|
|
)
|
|
|
|
|
2014-02-09 17:35:51 +01:00
|
|
|
# Generate LLVMConfig.cmake for the install tree.
|
|
|
|
set(LLVM_CONFIG_CODE "
|
|
|
|
# Compute the installation prefix from this LLVMConfig.cmake file location.
|
|
|
|
get_filename_component(LLVM_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 "${LLVM_INSTALL_PACKAGE_DIR}")
|
|
|
|
foreach(p ${_count})
|
|
|
|
set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
|
|
|
|
get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
|
|
|
|
endforeach(p)
|
|
|
|
set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
|
2014-12-29 12:16:19 +01:00
|
|
|
set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
|
2014-02-09 17:35:51 +01:00
|
|
|
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
2016-06-22 23:01:19 +02:00
|
|
|
set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
|
2014-07-22 19:48:51 +02:00
|
|
|
set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
|
2014-02-09 17:36:28 +01:00
|
|
|
set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
|
2016-09-09 21:45:34 +02:00
|
|
|
set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}")
|
2014-02-09 17:35:51 +01:00
|
|
|
configure_file(
|
|
|
|
LLVMConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
|
|
|
|
@ONLY)
|
|
|
|
|
|
|
|
# Generate LLVMConfigVersion.cmake for build and install tree.
|
2011-04-10 18:17:49 +02:00
|
|
|
configure_file(
|
|
|
|
LLVMConfigVersion.cmake.in
|
|
|
|
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
|
2010-09-14 01:59:48 +02:00
|
|
|
@ONLY)
|
2010-08-09 05:26:43 +02:00
|
|
|
|
2013-08-24 02:20:36 +02:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
2016-11-08 06:02:18 +01:00
|
|
|
get_property(llvm_has_exports GLOBAL PROPERTY LLVM_HAS_EXPORTS)
|
|
|
|
if(llvm_has_exports)
|
|
|
|
install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
|
|
|
|
COMPONENT cmake-exports)
|
|
|
|
endif()
|
2014-02-10 21:44:57 +01:00
|
|
|
|
2013-08-24 02:20:36 +02:00
|
|
|
install(FILES
|
2014-02-09 17:35:51 +01:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
|
2013-08-24 02:20:36 +02:00
|
|
|
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
|
|
|
|
LLVM-Config.cmake
|
2016-10-24 23:40:15 +02:00
|
|
|
DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
|
|
|
|
COMPONENT cmake-exports)
|
2011-02-03 21:57:36 +01:00
|
|
|
|
2013-08-24 02:20:36 +02:00
|
|
|
install(DIRECTORY .
|
2014-02-09 17:35:29 +01:00
|
|
|
DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
|
2016-10-24 23:40:15 +02:00
|
|
|
COMPONENT cmake-exports
|
2013-08-24 02:20:36 +02:00
|
|
|
FILES_MATCHING PATTERN *.cmake
|
|
|
|
PATTERN .svn EXCLUDE
|
|
|
|
PATTERN LLVMConfig.cmake EXCLUDE
|
|
|
|
PATTERN LLVMConfigVersion.cmake EXCLUDE
|
|
|
|
PATTERN LLVM-Config.cmake EXCLUDE
|
2016-08-25 22:53:00 +02:00
|
|
|
PATTERN GetHostTriple.cmake EXCLUDE)
|
2016-10-24 23:40:15 +02:00
|
|
|
|
2018-10-15 23:20:02 +02:00
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
2016-10-24 23:40:15 +02:00
|
|
|
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
|
|
|
|
add_custom_target(cmake-exports)
|
2017-11-30 22:48:26 +01:00
|
|
|
add_llvm_install_targets(install-cmake-exports
|
|
|
|
COMPONENT cmake-exports)
|
2016-10-24 23:40:15 +02:00
|
|
|
endif()
|
2013-08-24 02:20:36 +02:00
|
|
|
endif()
|