build: Move -s additional compiler flags into linker flags, and enable it only when gcc/clang are used. (#1087)

Compiler when compiling doesn't use them in those cases and emit a
warning, which is turned into an error by `-Werror`. Unfortunately,
CPack doesn't expose the logic it uses for stripping binaries.
This commit is contained in:
KOLANICH
2023-05-20 11:37:57 +00:00
committed by GitHub
parent 608c9e2e7a
commit 749823e044
7 changed files with 9 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
include(FetchContent)
if(IMHEX_STRIP_RELEASE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CPACK_STRIP_FILES TRUE)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_link_options($<$<CONFIG:RELEASE>:-s>)
endif()
endif()
macro(addDefines)