Author: John Ericson Date: 2022-07-28T19:36:40-04:00 New Revision: cc56a5022c94710d8393f1505f925494f7d2cc1c
URL: https://github.com/llvm/llvm-project/commit/cc56a5022c94710d8393f1505f925494f7d2cc1c DIFF: https://github.com/llvm/llvm-project/commit/cc56a5022c94710d8393f1505f925494f7d2cc1c.diff LOG: [clang][lld][cmake] Simplify header dirs We don't need to recompute the list LLVMConfig.cmake provides us. When LLVM is being built, the list is two elements long: generated headers and headers from source. When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources. Reviewed By: sebastian-ne Differential Revision: https://reviews.llvm.org/D130553 Added: Modified: clang/CMakeLists.txt lld/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c27beec313d7..480f13e73c9f 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -78,15 +78,17 @@ if(CLANG_BUILT_STANDALONE) if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. - set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") # N.B. this is just a default value, the CACHE PATHs below can be overriden. set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") + else() + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") endif() - set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") @@ -128,7 +130,7 @@ if(CLANG_BUILT_STANDALONE) set(LLVM_INCLUDE_TESTS ON) endif() - include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}") + include_directories(${LLVM_INCLUDE_DIRS}) link_directories("${LLVM_LIBRARY_DIR}") set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index dcc649629a4b..58dca54642e4 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -70,13 +70,15 @@ if(LLD_BUILT_STANDALONE) if (NOT LLVM_CONFIG_FOUND) # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config # path is removed. - set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") # N.B. this is just a default value, the CACHE PATHs below can be overridden. set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") + else() + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") endif() - set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") @@ -95,7 +97,7 @@ if(LLD_BUILT_STANDALONE) set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") - include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS}) + include_directories(${LLVM_INCLUDE_DIRS}) link_directories(${LLVM_LIBRARY_DIRS}) if(LLVM_INCLUDE_TESTS) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits