diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec54d6..bad0b24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ function(give_options_without_warnings target) set(BUILD_FLAGS_RELEASE -O3 - -flto=auto + -flto=$,thin,auto> -mavx -mavx2 -Wl,--gc-sections -fdata-sections @@ -173,6 +173,10 @@ function(give_options_without_warnings target) $<$:-fstack-protector-all -fsanitize=undefined -fsanitize=address> $<$:-gsource-map>) + set(BUILD_SHARED_LIBRARY_FLAGS_RELEASE + $<$:-Wl,-plugin-opt,cache-dir=${CMAKE_CURRENT_BINARY_DIR}/linker-cache/> + $<$:-Wl,-plugin-opt,cache-policy=prune_after=30m>) + target_compile_options(${target} PUBLIC ${BUILD_FLAGS} $<$:${BUILD_FLAGS_RELEASE}> @@ -186,6 +190,15 @@ function(give_options_without_warnings target) -Bsymbolic-functions $<$:-Wl,--hash-style=gnu>) + get_target_property(target_type ${target} TYPE) + if (target_type MATCHES SHARED_LIBRARY) + target_compile_options(${target} PUBLIC + $<$:${BUILD_SHARED_LIBRARY_FLAGS_RELEASE}>) + + target_link_options(${target} PUBLIC + $<$:${BUILD_SHARED_LIBRARY_FLAGS_RELEASE}>) + endif() + target_compile_definitions(${target} PRIVATE $<$:TWN_FEATURE_DYNLIB_GAME> $<$:_GNU_SOURCE>)