[libcxx] Add LIBCXX_EXTRA_SITE_DEFINES for adding extra defines in __config_site
This is similar to the existing setting LIBCXX_ABI_DEFINES, with
the difference that this also allows setting other defines than
ones that start with "_LIBCPP_ABI_", and allows setting defines
to a specific value.
This allows avoiding using LIBCXX_TEST_COMPILER_FLAGS in two
CI configurations.
Differential Revision: https://reviews.llvm.org/D116109
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 39744bb..03a6a07 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -196,6 +196,7 @@
option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF)
set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
+option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site")
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
set(LIBCXX_LIBCPPABI_VERSION "2" CACHE STRING "Version of libc++abi's ABI to re-export from libc++ when re-exporting is enabled.
Note that this is not related to the version of libc++'s ABI itself!")
@@ -909,6 +910,17 @@
config_define(${abi_defines} _LIBCPP_ABI_DEFINES)
endif()
+if (LIBCXX_EXTRA_SITE_DEFINES)
+ set(extra_site_defines)
+ foreach (extra_site_define ${LIBCXX_EXTRA_SITE_DEFINES})
+ # Allow defines such as DEFINE=VAL, transformed into "#define DEFINE VAL".
+ string(REPLACE "=" " " extra_site_define "${extra_site_define}")
+ list(APPEND extra_site_defines "#define ${extra_site_define}")
+ endforeach()
+ string(REPLACE ";" "\n" extra_site_defines "${extra_site_defines}")
+ config_define(${extra_site_defines} _LIBCPP_EXTRA_SITE_DEFINES)
+endif()
+
# By default libc++ on Windows expects to use a shared library, which requires
# the headers to use DLL import/export semantics. However when building a
# static library only we modify the headers to disable DLL import/export.