MacOS fixes

This commit is contained in:
2024-01-24 15:55:44 -08:00
parent d76ac2a254
commit 35cf3f3132
3 changed files with 43 additions and 33 deletions

View File

@@ -21,7 +21,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"MinSizeRel" "RelWithDebInfo")
endif()
add_compile_options(-fdata-sections -ffunction-sections)
add_compile_options(-fdata-sections -ffunction-sections
-Wno-return-stack-address)
if(APPLE)
add_link_options(-Wl,-dead_strip)
else()
@@ -54,19 +55,13 @@ target_link_options(${PROJECT_NAME} PRIVATE $<$<NOT:$<CONFIG:Debug>>:
add_library(${PROJECT_NAME}_static STATIC ConflictSet.cpp)
target_compile_options(conflict_set_static PRIVATE -fno-exceptions
-fvisibility=hidden)
add_custom_command(
TARGET conflict_set_static
POST_BUILD
COMMAND
${CMAKE_OBJCOPY} --keep-global-symbols=${CMAKE_SOURCE_DIR}/symbols.txt
$<TARGET_FILE:${PROJECT_NAME}_static>)
if(APPLE)
target_link_options(
${PROJECT_NAME}
PRIVATE
"LINKER:-no_weak_exports,-exported_symbols_list,${CMAKE_SOURCE_DIR}/symbols.txt"
)
if(NOT APPLE AND CMAKE_OBJCOPY)
add_custom_command(
TARGET conflict_set_static
POST_BUILD
COMMAND
${CMAKE_OBJCOPY} --keep-global-symbols=${CMAKE_SOURCE_DIR}/symbols.txt
$<TARGET_FILE:${PROJECT_NAME}_static>)
endif()
set(TEST_FLAGS -Wall -Wextra -Wpedantic -Wunreachable-code -UNDEBUG)
@@ -82,8 +77,8 @@ target_compile_definitions(conflict_set_main PRIVATE ENABLE_MAIN)
set(FUZZ_FLAGS "-fsanitize=fuzzer-no-link,address,undefined")
include(CheckCXXCompilerFlag)
cmake_push_check_state()
set(CMAKE_REQUIRED_LINK_OPTIONS ${FUZZ_FLAGS})
check_cxx_compiler_flag(${FUZZ_FLAGS} HAS_LIB_FUZZER)
set(CMAKE_REQUIRED_LINK_OPTIONS -fsanitize=fuzzer)
check_cxx_compiler_flag(-fsanitize=fuzzer HAS_LIB_FUZZER)
cmake_pop_check_state()
if(HAS_LIB_FUZZER)