2022-05-14 13:07:12 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/common_compile_options.cmake)
|
|
|
|
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-Wno-maybe-uninitialized)
|
|
|
|
add_cxx_compile_options(-Wno-shorten-64-to-32)
|
2024-06-06 08:36:16 +00:00
|
|
|
|
|
|
|
if(NOT MSVC)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fsigned-char)
|
|
|
|
add_cxx_compile_options(-ggnu-pubnames)
|
2024-06-06 08:36:16 +00:00
|
|
|
else()
|
|
|
|
# char is signed
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(/J)
|
2024-06-06 08:36:16 +00:00
|
|
|
# full symbolic debugginng information
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(/Z7)
|
2024-06-06 08:36:16 +00:00
|
|
|
endif()
|
|
|
|
|
2022-12-12 21:57:36 +00:00
|
|
|
if (NOT WIN32)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fPIC)
|
2022-12-12 21:57:36 +00:00
|
|
|
endif()
|
2023-09-05 05:40:57 +00:00
|
|
|
|
2024-01-16 10:56:23 +00:00
|
|
|
if (LINUX)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_compile_definitions(_FILE_OFFSET_BITS=64)
|
2024-01-16 10:56:23 +00:00
|
|
|
endif()
|
|
|
|
|
2024-06-19 23:01:41 +00:00
|
|
|
if (APPLE)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH /opt/homebrew)
|
|
|
|
endif()
|
|
|
|
|
2023-12-20 16:36:02 +00:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2024-06-06 08:36:16 +00:00
|
|
|
if (NOT MSVC)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-ggdb3)
|
2024-06-06 08:36:16 +00:00
|
|
|
endif()
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-Og)
|
2023-12-20 16:36:02 +00:00
|
|
|
else()
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-O2)
|
2024-10-09 21:38:58 +00:00
|
|
|
if (NOT MSVC)
|
|
|
|
add_cxx_compile_options(-g1)
|
|
|
|
endif()
|
2023-12-20 16:36:02 +00:00
|
|
|
endif()
|
|
|
|
|
2024-07-19 21:54:52 +00:00
|
|
|
function(add_cxx_linker_flag_if_supported flag)
|
2023-09-05 05:40:57 +00:00
|
|
|
include(CheckLinkerFlag)
|
|
|
|
|
|
|
|
check_linker_flag(CXX ${flag} LAGOM_LINKER_SUPPORTS_${flag})
|
|
|
|
if (${LAGOM_LINKER_SUPPORTS_${flag}})
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_link_options(${flag})
|
2023-09-05 05:40:57 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2023-08-30 06:46:13 +00:00
|
|
|
if (NOT WIN32)
|
|
|
|
add_cxx_linker_flag_if_supported(LINKER:--gdb-index)
|
2023-09-10 20:09:22 +00:00
|
|
|
|
2023-08-30 06:46:13 +00:00
|
|
|
if (NOT ENABLE_FUZZERS)
|
|
|
|
add_cxx_linker_flag_if_supported(LINKER:-Bsymbolic-non-weak-functions)
|
|
|
|
endif()
|
2023-09-10 20:09:22 +00:00
|
|
|
endif()
|
2024-02-24 17:17:57 +00:00
|
|
|
|
|
|
|
if (ENABLE_LAGOM_COVERAGE_COLLECTION)
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND NOT ENABLE_FUZZERS)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
|
|
|
add_cxx_link_options(-fprofile-instr-generate)
|
2024-02-24 17:17:57 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Collecting code coverage is unsupported in this configuration.")
|
|
|
|
endif()
|
|
|
|
endif()
|