diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -234,23 +234,23 @@ list(APPEND out_files ${dst}) add_custom_target(generate-cxx-headers DEPENDS ${out_files}) - add_library(${CXX_HEADER_TARGET} INTERFACE) - add_dependencies(${CXX_HEADER_TARGET} generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET}) + add_library(cxx-headers INTERFACE) + add_dependencies(cxx-headers generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET}) # TODO: Use target_include_directories once we figure out why that breaks the runtimes build if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - target_compile_options(${CXX_HEADER_TARGET} INTERFACE /I "${output_dir}") + target_compile_options(cxx-headers INTERFACE /I "${output_dir}") else() - target_compile_options(${CXX_HEADER_TARGET} INTERFACE -I "${output_dir}") + target_compile_options(cxx-headers INTERFACE -I "${output_dir}") endif() # Make sure the generated __config_site header is included when we build the library. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - target_compile_options(${CXX_HEADER_TARGET} INTERFACE /FI "${LIBCXX_BINARY_DIR}/__config_site") + target_compile_options(cxx-headers INTERFACE /FI "${LIBCXX_BINARY_DIR}/__config_site") else() - target_compile_options(${CXX_HEADER_TARGET} INTERFACE -include "${LIBCXX_BINARY_DIR}/__config_site") + target_compile_options(cxx-headers INTERFACE -include "${LIBCXX_BINARY_DIR}/__config_site") endif() else() - add_library(${CXX_HEADER_TARGET} INTERFACE) + add_library(cxx-headers INTERFACE) endif() if (LIBCXX_INSTALL_HEADERS) @@ -258,7 +258,7 @@ get_filename_component(dir ${file} DIRECTORY) install(FILES ${file} DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir} - COMPONENT ${CXX_HEADER_TARGET} + COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) endforeach() @@ -268,15 +268,15 @@ DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ RENAME __config - COMPONENT ${CXX_HEADER_TARGET}) + COMPONENT cxx-headers) if (NOT CMAKE_CONFIGURATION_TYPES) - add_custom_target(install-${CXX_HEADER_TARGET} - DEPENDS ${CXX_HEADER_TARGET} cxx-generated-config + add_custom_target(install-cxx-headers + DEPENDS cxx-headers cxx-generated-config COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=${CXX_HEADER_TARGET} + -DCMAKE_INSTALL_COMPONENT=cxx-headers -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") # Stripping is a no-op for headers - add_custom_target(install-${CXX_HEADER_TARGET}-stripped DEPENDS install-${CXX_HEADER_TARGET}) + add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers) endif() endif() diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -99,9 +99,14 @@ include(CheckLibraryExists) include(CheckCCompilerFlag) - # We don't have libc++ (yet). + # We don't have libc++ (yet)... set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") + # ...but we need access to libc++ headers for CMake checks to succeed. + if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -isystem ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include") + endif() + # Avoid checking whether the compiler is working. set(LLVM_COMPILER_CHECKED ON) @@ -215,15 +220,6 @@ else() # if this is included from LLVM's CMake include(LLVMExternalProjectUtils) - if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR AND "libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) - # This looks wrong, but libcxx's build actually wants the header dir to be - # the root build dir, not the include directory. - set(LIBCXX_BINARY_DIR ${LLVM_BINARY_DIR}) - set(LIBCXX_SOURCE_DIR ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}) - set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) - set(CXX_HEADER_TARGET runtime-libcxx-headers) - add_subdirectory(${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}/include ${CXX_HEADER_TARGET}) - endif() if(NOT LLVM_BUILD_RUNTIMES) set(EXTRA_ARGS EXCLUDE_FROM_ALL) @@ -420,7 +416,7 @@ llvm_ExternalProject_Add(runtimes ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${ARG_DEPENDS} ${CXX_HEADER_TARGET} + DEPENDS ${ARG_DEPENDS} # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS} @@ -531,7 +527,7 @@ llvm_ExternalProject_Add(runtimes-${name} ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${${name}_deps} ${CXX_HEADER_TARGET} + DEPENDS ${${name}_deps} # Builtins were built separately above CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}