[libc++] Add a per-target flag to include the generated config_site

This allows propagating the include automatically to targets that
depend on one of the libc++ targets such as the benchmarks. Note
that the GoogleBenchmark build itself still needs to manually specify
the -include, since I don't know of any way to have an external project
link against one of the libc++ targets (which would propagate the -include
automatically).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@373631 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Louis Dionne 2019-10-03 17:20:50 +00:00
parent d3253a749c
commit 8937697dbc
3 changed files with 15 additions and 17 deletions

View File

@ -809,20 +809,20 @@ if (LIBCXX_NEEDS_SITE_CONFIG)
configure_file("include/__config_site.in" configure_file("include/__config_site.in"
"${site_config_path}" "${site_config_path}"
@ONLY) @ONLY)
elseif(EXISTS "${site_config_path}")
# Provide the config definitions by included the generated __config_site
# file at compile time.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"")
else()
add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
endif()
else()
if (EXISTS "${site_config_path}")
message(STATUS "Removing stale site configuration ${site_config_path}") message(STATUS "Removing stale site configuration ${site_config_path}")
file(REMOVE "${site_config_path}") file(REMOVE "${site_config_path}")
endif() endif()
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() endif()
endif()
endfunction()
#=============================================================================== #===============================================================================
# Setup Source Code And Tests # Setup Source Code And Tests

View File

@ -95,10 +95,6 @@ set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
${SANITIZER_FLAGS} ${SANITIZER_FLAGS}
-Wno-user-defined-literals -Wno-user-defined-literals
) )
if (LIBCXX_NEEDS_SITE_CONFIG)
list(APPEND BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
-include "${LIBCXX_BINARY_DIR}/__config_site")
endif()
set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS
-nodefaultlibs -nodefaultlibs

View File

@ -234,6 +234,7 @@ if (LIBCXX_ENABLE_SHARED)
cxx_set_common_defines(cxx_shared) cxx_set_common_defines(cxx_shared)
cxx_add_warning_flags(cxx_shared) cxx_add_warning_flags(cxx_shared)
cxx_add_windows_flags(cxx_shared) cxx_add_windows_flags(cxx_shared)
cxx_add_config_site(cxx_shared)
# Link against LLVM libunwind # Link against LLVM libunwind
if (LIBCXXABI_USE_LLVM_UNWINDER) if (LIBCXXABI_USE_LLVM_UNWINDER)
@ -337,6 +338,7 @@ if (LIBCXX_ENABLE_STATIC)
cxx_set_common_defines(cxx_static) cxx_set_common_defines(cxx_static)
cxx_add_warning_flags(cxx_static) cxx_add_warning_flags(cxx_static)
cxx_add_windows_flags(cxx_static) cxx_add_windows_flags(cxx_static)
cxx_add_config_site(cxx_static)
if (LIBCXX_HERMETIC_STATIC_LIBRARY) if (LIBCXX_HERMETIC_STATIC_LIBRARY)
# If the hermetic library doesn't define the operator new/delete functions # If the hermetic library doesn't define the operator new/delete functions