diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt --- a/llvm/cmake/modules/CMakeLists.txt +++ b/llvm/cmake/modules/CMakeLists.txt @@ -34,7 +34,10 @@ list(REMOVE_ITEM LLVM_COMMON_DEPENDS omp_gen) endif() +# # 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}\") @@ -42,21 +45,24 @@ set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\") set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\") ") + +set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_MAIN_INCLUDE_DIR}") +set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") set(LLVM_CONFIG_INCLUDE_DIRS - "${LLVM_MAIN_INCLUDE_DIR}" - "${LLVM_INCLUDE_DIR}" - ) -set(LLVM_CONFIG_INCLUDE_DIR - "${LLVM_INCLUDE_DIR}" - ) -set(LLVM_CONFIG_MAIN_INCLUDE_DIR - "${LLVM_MAIN_INCLUDE_DIR}" + "${LLVM_CONFIG_MAIN_INCLUDE_DIR}" + "${LLVM_CONFIG_INCLUDE_DIR}" ) +list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) + +set(LLVM_CONFIG_LIBRARY_DIR "${LLVM_LIBRARY_DIR}") set(LLVM_CONFIG_LIBRARY_DIRS - "${LLVM_LIBRARY_DIR}" + "${LLVM_CONFIG_LIBRARY_DIR}" + # FIXME: Should there be other entries here? ) -set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +list(REMOVE_DUPLICATES LLVM_CONFIG_LIBRARY_DIRS) + set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}") +set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") # Generate a default location for lit @@ -98,7 +104,10 @@ PATTERN CMakeFiles EXCLUDE ) +# # 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)") @@ -109,12 +118,26 @@ 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") -set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}") -set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}") -set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") -set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") + +set(LLVM_CONFIG_MAIN_INCLUDE_DIR "\${LLVM_INSTALL_PREFIX}/include") +# This is the same as the above because the handwritten and generated headers +# are combined in one directory at install time. +set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_MAIN_INCLUDE_DIR}") +set(LLVM_CONFIG_INCLUDE_DIRS + "${LLVM_CONFIG_MAIN_INCLUDE_DIR}" + "${LLVM_CONFIG_INCLUDE_DIR}" + ) +list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) + +set(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") +set(LLVM_CONFIG_LIBRARY_DIRS + "${LLVM_CONFIG_LIBRARY_DIR}" + # FIXME: Should there be other entries here? + ) +list(REMOVE_DUPLICATES LLVM_CONFIG_LIBRARY_DIRS) + set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") +set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") # Generate a default location for lit diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -110,13 +110,17 @@ # values for build tree. LLVM_INCLUDE_DIRS contains both source # and generated include directories while the following variables have # them split. -set(LLVM_INCLUDE_DIR "@LLVM_CONFIG_INCLUDE_DIR@") + +# These are the "main" dirs set(LLVM_MAIN_INCLUDE_DIR "@LLVM_CONFIG_MAIN_INCLUDE_DIR@") -set(LLVM_LIBRARY_DIR "@LLVM_CONFIG_LIBRARY_DIRS@") +set(LLVM_LIBRARY_DIR "@LLVM_CONFIG_LIBRARY_DIR@") + +# This is a secondary one for generated files +set(LLVM_INCLUDE_DIR "@LLVM_CONFIG_INCLUDE_DIR@") set(LLVM_DEFINITIONS "@LLVM_DEFINITIONS@") -set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@") set(LLVM_BINARY_DIR "@LLVM_CONFIG_BINARY_DIR@") +set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@") set(LLVM_TOOLS_BINARY_DIR "@LLVM_CONFIG_TOOLS_BINARY_DIR@") set(LLVM_TOOLS_INSTALL_DIR "@LLVM_TOOLS_INSTALL_DIR@") set(LLVM_HAVE_OPT_VIEWER_MODULES @LLVM_HAVE_OPT_VIEWER_MODULES@)