diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -874,22 +874,15 @@ endif() set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site") -if (LIBCXX_NEEDS_SITE_CONFIG) - configure_file("include/__config_site.in" - "${site_config_path}" - @ONLY) -elseif(EXISTS "${site_config_path}") - message(STATUS "Removing stale site configuration ${site_config_path}") - file(REMOVE "${site_config_path}") -endif() +configure_file("include/__config_site.in" + "${site_config_path}" + @ONLY) function(cxx_add_config_site target) - if (LIBCXX_NEEDS_SITE_CONFIG) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - target_compile_options(${target} PUBLIC /FI "${site_config_path}") - else() - target_compile_options(${target} PUBLIC -include "${site_config_path}") - endif() + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(${target} PUBLIC /FI "${site_config_path}") + else() + target_compile_options(${target} PUBLIC -include "${site_config_path}") endif() endfunction() diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -18,9 +18,7 @@ -L${LIBCXX_CXX_ABI_LIBRARY_PATH} -Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH}) endif() -if (LIBCXX_NEEDS_SITE_CONFIG) - list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS -include "${LIBCXX_BINARY_DIR}/__config_site") -endif() +list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS -include "${LIBCXX_BINARY_DIR}/__config_site") split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS) ExternalProject_Add(google-benchmark-libcxx diff --git a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake --- a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake +++ b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake @@ -88,20 +88,17 @@ macro(config_define_if condition def) if (${condition}) set(${def} ON) - set(LIBCXX_NEEDS_SITE_CONFIG ON) endif() endmacro() macro(config_define_if_not condition def) if (NOT ${condition}) set(${def} ON) - set(LIBCXX_NEEDS_SITE_CONFIG ON) endif() endmacro() macro(config_define value def) set(${def} ${value}) - set(LIBCXX_NEEDS_SITE_CONFIG ON) endmacro() # Add a list of flags to all of 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -184,27 +184,20 @@ ) endif() -if (LIBCXX_NEEDS_SITE_CONFIG) - # Generate a custom __config header. The new header is created - # by prepending __config_site to the current __config header. - add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config - COMMAND ${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py - ${LIBCXX_BINARY_DIR}/__config_site - ${LIBCXX_SOURCE_DIR}/include/__config - -o ${LIBCXX_BINARY_DIR}/__generated_config - DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config - ${LIBCXX_BINARY_DIR}/__config_site - ) - # Add a target that executes the generation commands. - add_custom_target(cxx-generated-config ALL - DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config) - set(generated_config_deps cxx-generated-config) -else() - set(files - ${files} - __config - ) -endif() +# Generate a custom __config header. The new header is created +# by prepending __config_site to the current __config header. +add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config + COMMAND ${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py + ${LIBCXX_BINARY_DIR}/__config_site + ${LIBCXX_SOURCE_DIR}/include/__config + -o ${LIBCXX_BINARY_DIR}/__generated_config + DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config + ${LIBCXX_BINARY_DIR}/__config_site +) +# Add a target that executes the generation commands. +add_custom_target(cxx-generated-config ALL + DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config) +set(generated_config_deps cxx-generated-config) # In some build configurations (like bootstrapping clang), we need to be able to # install the libcxx headers before the CMake configuration for libcxx runs. Making @@ -228,16 +221,14 @@ list(APPEND out_files ${dst}) endforeach() - if (LIBCXX_NEEDS_SITE_CONFIG) - # Copy the generated header as __config into build directory. - set(src ${LIBCXX_BINARY_DIR}/__generated_config) - set(dst ${output_dir}/__config) - add_custom_command(OUTPUT ${dst} - DEPENDS ${src} ${generated_config_deps} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying CXX __config") - list(APPEND out_files ${dst}) - endif() + # Copy the generated header as __config into build directory. + set(src ${LIBCXX_BINARY_DIR}/__generated_config) + set(dst ${output_dir}/__config) + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} ${generated_config_deps} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying CXX __config") + list(APPEND out_files ${dst}) add_custom_target(${CXX_HEADER_TARGET} ALL DEPENDS ${out_files} ${LIBCXX_CXX_ABI_HEADER_TARGET}) else() @@ -255,14 +246,12 @@ ) endforeach() - if (LIBCXX_NEEDS_SITE_CONFIG) - # Install the generated header as __config. - install(FILES ${LIBCXX_BINARY_DIR}/__generated_config - DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1 - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - RENAME __config - COMPONENT ${CXX_HEADER_TARGET}) - endif() + # Install the generated header as __config. + install(FILES ${LIBCXX_BINARY_DIR}/__generated_config + DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + RENAME __config + COMPONENT ${CXX_HEADER_TARGET}) if (NOT CMAKE_CONFIGURATION_TYPES) add_custom_target(install-${CXX_HEADER_TARGET}