diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -268,7 +268,11 @@ openmp_wrappers/new ) -set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include) +if(NOT CLANG_RESOURCE_DIR STREQUAL "") + set(output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_RESOURCE_DIR}/include) +else() + set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include) +endif() set(out_files) set(generated_files) @@ -425,7 +429,11 @@ add_header_target("windows-resource-headers" ${windows_only_files}) add_header_target("utility-resource-headers" ${utility_files}) -set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) +if(NOT CLANG_RESOURCE_DIR STREQUAL "") + set(header_install_dir ${CMAKE_INSTALL_BINDIR}/${CLANG_RESOURCE_DIR}/include) +else() + set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) +endif() ############################################################# # Install rules for the catch-all clang-resource-headers target diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -52,6 +52,11 @@ list(APPEND implicitDirs -I ${implicitDir}) endforeach() + if(NOT CLANG_RESOURCE_DIR STREQUAL "") + set(resource_include_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR}/include) + else() + set(resource_include_dir ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include) + endif() add_custom_command( COMMENT Generate ASTNodeAPI.json OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json @@ -60,7 +65,7 @@ $ # Skip this in debug mode because parsing AST.h is too slow --skip-processing=${skip_expensive_processing} - -I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include + -I ${resource_include_dir} -I ${CLANG_SOURCE_DIR}/include -I ${LLVM_BINARY_DIR}/tools/clang/include -I ${LLVM_BINARY_DIR}/include diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt @@ -66,6 +66,14 @@ list(APPEND compiler_rt_configure_deps LLVMTestingSupport) endif() + if(NOT CLANG_RESOURCE_DIR STREQUAL "") + set(output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_RESOURCE_DIR}) + set(resource_dir bin/${CLANG_RESOURCE_DIR}) + else() + set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) + set(resource_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) + endif() + ExternalProject_Add(compiler-rt DEPENDS llvm-config clang ${compiler_rt_configure_deps} PREFIX ${COMPILER_RT_PREFIX} @@ -82,9 +90,9 @@ -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS} - -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION} + -DCOMPILER_RT_OUTPUT_DIR=${output_dir} -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR} - -DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION} + -DCOMPILER_RT_INSTALL_PATH:PATH=${resource_dir} -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -43,9 +43,14 @@ string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) # Setup the paths where compiler-rt runtimes and headers should be stored. - set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") + set(COMPILER_RT_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_RESOURCE_DIR}) + set(COMPILER_RT_INSTALL_PATH bin/${CLANG_RESOURCE_DIR}) + else() + set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) + set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) + endif() set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." ${LLVM_INCLUDE_TESTS}) option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake --- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake +++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake @@ -257,7 +257,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) - set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}") + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") + set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR}) + else() + set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}") + endif() set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER) foreach(type ${flag_types}) set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir}) diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -80,7 +80,11 @@ set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") else() string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) - set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") + if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "") + set(LIBOMP_HEADERS_INSTALL_PATH ${CMAKE_INSTALL_BINDIR}/${CLANG_RESOURCE_DIR}/include) + else() + set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") + endif() endif() # Build host runtime library, after LIBOMPTARGET variables are set since they are needed