diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -139,50 +139,9 @@ string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") endif() -macro(cxxabi_object_library name) - cmake_parse_arguments(ARGS "" "" "DEFINES;FLAGS" ${ARGN}) - - # Add a object library that contains the compiled source files. - add_library(${name} OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) - set_target_properties(${name} - PROPERTIES - CXX_EXTENSIONS - OFF - CXX_STANDARD - 11 - CXX_STANDARD_REQUIRED - ON - COMPILE_FLAGS - "${LIBCXXABI_COMPILE_FLAGS}") - - if(ARGS_DEFINES) - target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES}) - endif() - - if(ARGS_FLAGS) - target_compile_options(${name} PRIVATE ${ARGS_FLAGS}) - endif() -endmacro() - -if(LIBCXXABI_HERMETIC_STATIC_LIBRARY) - append_flags_if_supported(CXXABI_STATIC_OBJECTS_FLAGS -fvisibility=hidden) - append_flags_if_supported(CXXABI_STATIC_OBJECTS_FLAGS -fvisibility-global-new-delete-hidden) - cxxabi_object_library(cxxabi_static_objects - DEFINES - _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS - _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS - FLAGS ${CXXABI_STATIC_OBJECTS_FLAGS}) -else() - cxxabi_object_library(cxxabi_static_objects) -endif() - -cxxabi_object_library(cxxabi_shared_objects POSITION_INDEPENDENT_CODE ON) -set(cxxabi_static_sources $) -set(cxxabi_shared_sources $) - # Build the shared library. if (LIBCXXABI_ENABLE_SHARED) - add_library(cxxabi_shared SHARED ${cxxabi_shared_sources}) + add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) if(COMMAND llvm_setup_rpath) llvm_setup_rpath(cxxabi_shared) endif() @@ -195,6 +154,8 @@ 11 CXX_STANDARD_REQUIRED ON + COMPILE_FLAGS + "${LIBCXXABI_COMPILE_FLAGS}" LINK_FLAGS "${LIBCXXABI_LINK_FLAGS} ${LIBCXXABI_SHARED_LINK_FLAGS}" OUTPUT_NAME @@ -213,16 +174,7 @@ # Build the static library. if (LIBCXXABI_ENABLE_STATIC) - if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) - if (TARGET unwind_static OR HAVE_LIBUNWIND) - if(LIBUNWIND_HERMETIC_STATIC_LIBRARY) - list(APPEND cxxabi_static_sources $) - else() - list(APPEND cxxabi_static_sources $) - endif() - endif() - endif() - add_library(cxxabi_static STATIC ${cxxabi_static_sources}) + add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) target_link_libraries(cxxabi_static PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) set_target_properties(cxxabi_static PROPERTIES @@ -232,10 +184,31 @@ 11 CXX_STANDARD_REQUIRED ON + COMPILE_FLAGS + "${LIBCXXABI_COMPILE_FLAGS}" LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" OUTPUT_NAME "c++abi") + + if (LIBCXXABI_HERMETIC_STATIC_LIBRARY) + append_flags_if_supported(CXXABI_STATIC_OBJECTS_FLAGS -fvisibility=hidden) + append_flags_if_supported(CXXABI_STATIC_OBJECTS_FLAGS -fvisibility-global-new-delete-hidden) + target_compile_options(cxxabi_static PRIVATE ${CXXABI_STATIC_OBJECTS_FLAGS}) + target_compile_definitions(cxxabi_static PRIVATE _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS + _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) + endif() + + if (LIBCXXABI_USE_LLVM_UNWINDER AND + LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND + (TARGET unwind_static OR HAVE_LIBUNWIND)) + if(LIBUNWIND_HERMETIC_STATIC_LIBRARY) + target_sources(cxxabi_static PRIVATE $) + else() + target_sources(cxxabi_static PRIVATE $) + endif() + endif() + list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_static") if (LIBCXXABI_INSTALL_STATIC_LIBRARY) list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static")