diff options
author | Louis Dionne <ldionne@apple.com> | 2019-10-04 18:03:17 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-10-04 18:03:17 +0000 |
commit | 432ae75f8bb2d1e13e71ddd347fa356d87459e58 (patch) | |
tree | bcf17cf080c4b118397782477ce7d3a82706b04e | |
parent | 87aa59a0c7150bd6aff1de6959ec55eab28102ef (diff) | |
download | bcm5719-llvm-432ae75f8bb2d1e13e71ddd347fa356d87459e58.tar.gz bcm5719-llvm-432ae75f8bb2d1e13e71ddd347fa356d87459e58.zip |
[libc++] Move more CMake flags to per-target definitions
This daily refactoring tackles flags related to modules,
exceptions and RTTI.
llvm-svn: 373767
-rw-r--r-- | libcxx/CMakeLists.txt | 44 | ||||
-rw-r--r-- | libcxx/src/CMakeLists.txt | 6 |
2 files changed, 31 insertions, 19 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 1f7dd57dfc9..6170fde1646 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -630,22 +630,26 @@ function(cxx_add_warning_flags target) endfunction() # Exception flags ============================================================= -if (LIBCXX_ENABLE_EXCEPTIONS) - # Catches C++ exceptions only and tells the compiler to assume that extern C - # functions never throw a C++ exception. - add_compile_flags_if_supported(-EHsc) -else() - add_definitions(-D_LIBCPP_NO_EXCEPTIONS) - add_compile_flags_if_supported(-EHs- -EHa-) - add_compile_flags_if_supported(-fno-exceptions) -endif() +function(cxx_add_exception_flags target) + if (LIBCXX_ENABLE_EXCEPTIONS) + # Catches C++ exceptions only and tells the compiler to assume that extern C + # functions never throw a C++ exception. + target_add_compile_flags_if_supported(${target} PUBLIC -EHsc) + else() + target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_EXCEPTIONS) + target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-) + target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions) + endif() +endfunction() # RTTI flags ================================================================== -if (NOT LIBCXX_ENABLE_RTTI) - add_definitions(-D_LIBCPP_NO_RTTI) - add_compile_flags_if_supported(-GR-) - add_compile_flags_if_supported(-fno-rtti) -endif() +function(cxx_add_rtti_flags target) + if (NOT LIBCXX_ENABLE_RTTI) + target_compile_definitions(${target} PUBLIC -D_LIBCPP_NO_RTTI) + target_add_compile_flags_if_supported(${target} PUBLIC -GR-) + target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti) + endif() +endfunction() # Threading flags ============================================================= if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) @@ -672,11 +676,13 @@ endif() # FIXME The libc++ sources are fundamentally non-modular. They need special # versions of the headers in order to provide C++03 and legacy ABI definitions. # NOTE: The public headers can be used with modules in all other contexts. -if (LLVM_ENABLE_MODULES) - # Ignore that the rest of the modules flags are now unused. - add_compile_flags_if_supported(-Wno-unused-command-line-argument) - add_compile_flags(-fno-modules) -endif() +function(cxx_add_module_flags target) + if (LLVM_ENABLE_MODULES) + # Ignore that the rest of the modules flags are now unused. + target_add_compile_flags_if_supported(${target} PRIVATE -Wno-unused-command-line-argument) + target_compile_options(${target} PRIVATE -fno-modules) + endif() +endfunction() # Sanitizer flags ============================================================= diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt index 93d48f1b7dc..d0a510861a1 100644 --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -235,6 +235,9 @@ if (LIBCXX_ENABLE_SHARED) cxx_add_warning_flags(cxx_shared) cxx_add_windows_flags(cxx_shared) cxx_add_config_site(cxx_shared) + cxx_add_exception_flags(cxx_shared) + cxx_add_rtti_flags(cxx_shared) + cxx_add_module_flags(cxx_shared) # Link against LLVM libunwind if (LIBCXXABI_USE_LLVM_UNWINDER) @@ -339,6 +342,9 @@ if (LIBCXX_ENABLE_STATIC) cxx_add_warning_flags(cxx_static) cxx_add_windows_flags(cxx_static) cxx_add_config_site(cxx_static) + cxx_add_exception_flags(cxx_static) + cxx_add_rtti_flags(cxx_static) + cxx_add_module_flags(cxx_static) if (LIBCXX_HERMETIC_STATIC_LIBRARY) # If the hermetic library doesn't define the operator new/delete functions |