Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 69b7a5e

Browse files
authored
Merge pull request #21 from gottesmm/rdar27110616
Rdar27110616
2 parents 1b17245 + c061400 commit 69b7a5e

File tree

4 files changed

+59
-30
lines changed

4 files changed

+59
-30
lines changed

CMakeLists.txt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -606,28 +606,7 @@ endif()
606606

607607
if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
608608
CMAKE_VERSION VERSION_GREATER 3)
609-
# Generate a list of CMake library targets so that other CMake projects can
610-
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
611-
# the usual CMake convention seems to be ${Project}Targets.cmake.
612-
set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
613-
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
614-
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
615-
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
616-
617-
# Install a <prefix>/share/clang/cmake/ClangConfig.cmake file so that
618-
# find_package(Clang) works. Install the target list with it.
619-
install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
620-
621-
install(FILES
622-
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
623-
DESTINATION share/clang/cmake)
624-
625-
# Also copy ClangConfig.cmake to the build directory so that dependent projects
626-
# can build against a build directory of Clang more easily.
627-
configure_file(
628-
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
629-
${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
630-
COPYONLY)
609+
add_subdirectory(cmake/modules)
631610
endif ()
632611

633612
if (CLANG_ENABLE_BOOTSTRAP)

cmake/modules/CMakeLists.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Generate a list of CMake library targets so that other CMake projects can
2+
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
3+
# the usual CMake convention seems to be ${Project}Targets.cmake.
4+
set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
5+
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
6+
7+
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
8+
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
9+
10+
# Generate ClangConfig.cmake for the build tree.
11+
set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
12+
set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
13+
configure_file(
14+
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
15+
${clang_cmake_builddir}/ClangConfig.cmake
16+
@ONLY)
17+
set(CLANG_CONFIG_CMAKE_DIR)
18+
set(CLANG_CONFIG_EXPORTS_FILE)
19+
20+
# Generate ClangConfig.cmake for the install tree.
21+
set(CLANG_CONFIG_CODE "
22+
# Compute the installation prefix from this LLVMConfig.cmake file location.
23+
get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
24+
# Construct the proper number of get_filename_component(... PATH)
25+
# calls to compute the installation prefix.
26+
string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
27+
foreach(p ${_count})
28+
set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
29+
get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)")
30+
endforeach(p)
31+
set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
32+
set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
33+
configure_file(
34+
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
35+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
36+
@ONLY)
37+
set(CLANG_CONFIG_CODE)
38+
set(CLANG_CONFIG_CMAKE_DIR)
39+
set(CLANG_CONFIG_EXPORTS_FILE)
40+
41+
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
42+
install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
43+
44+
install(FILES
45+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
46+
DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
47+
endif()

cmake/modules/ClangConfig.cmake

Lines changed: 0 additions & 8 deletions
This file was deleted.

cmake/modules/ClangConfig.cmake.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file allows users to call find_package(Clang) and pick up our targets.
2+
3+
find_package(LLVM REQUIRED CONFIG)
4+
5+
@CLANG_CONFIG_CODE@
6+
7+
set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
8+
set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
9+
10+
# Provide all our library targets to users.
11+
include("@CLANG_CONFIG_EXPORTS_FILE@")

0 commit comments

Comments
 (0)