[libcxx-commits] [libcxx] r373631 - [libc++] Add a per-target flag to include the generated config_site
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 3 10:20:50 PDT 2019
Author: ldionne
Date: Thu Oct 3 10:20:50 2019
New Revision: 373631
URL: http://llvm.org/viewvc/llvm-project?rev=373631&view=rev
Log:
[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).
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/benchmarks/CMakeLists.txt
libcxx/trunk/src/CMakeLists.txt
Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=373631&r1=373630&r2=373631&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Oct 3 10:20:50 2019
@@ -809,20 +809,20 @@ 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()
- # 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}")
- file(REMOVE "${site_config_path}")
+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
Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=373631&r1=373630&r2=373631&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Thu Oct 3 10:20:50 2019
@@ -95,10 +95,6 @@ set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
${SANITIZER_FLAGS}
-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
-nodefaultlibs
Modified: libcxx/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/CMakeLists.txt?rev=373631&r1=373630&r2=373631&view=diff
==============================================================================
--- libcxx/trunk/src/CMakeLists.txt (original)
+++ libcxx/trunk/src/CMakeLists.txt Thu Oct 3 10:20:50 2019
@@ -234,6 +234,7 @@ if (LIBCXX_ENABLE_SHARED)
cxx_set_common_defines(cxx_shared)
cxx_add_warning_flags(cxx_shared)
cxx_add_windows_flags(cxx_shared)
+ cxx_add_config_site(cxx_shared)
# Link against LLVM libunwind
if (LIBCXXABI_USE_LLVM_UNWINDER)
@@ -337,6 +338,7 @@ if (LIBCXX_ENABLE_STATIC)
cxx_set_common_defines(cxx_static)
cxx_add_warning_flags(cxx_static)
cxx_add_windows_flags(cxx_static)
+ cxx_add_config_site(cxx_static)
if (LIBCXX_HERMETIC_STATIC_LIBRARY)
# If the hermetic library doesn't define the operator new/delete functions
More information about the libcxx-commits
mailing list