CMakeLists.txt: Find a self-packer and use it if it's found (except when CMAKE_BUILD_TYPE is set to Debug or RelWithDebInfo)

Add the --ultra-brute flag when upx is found

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-06-11 16:11:06 +02:00
parent 6afec609b0
commit 7b6e2165ba
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 11 additions and 0 deletions

View File

@ -152,6 +152,17 @@ if (Threads_FOUND)
target_link_libraries(${EXENAME} PRIVATE Threads::Threads)
endif()
option(NO_SELF_PACKER "Disables usage of a self-packer")
if (NOT (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR NO_SELF_PACKER OR DEFINED EMSCRIPTEN))
include(FindSelfPackers)
if (SELF_PACKER_FOR_EXECUTABLE MATCHES upx)
set(SELF_PACKER_FOR_EXECUTABLE_FLAGS ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} --ultra-brute)
endif()
if (NOT SELF_PACKER_FOR_EXECUTABLE EQUAL "")
add_custom_command(TARGET ${EXENAME} POST_BUILD COMMAND "${SELF_PACKER_FOR_EXECUTABLE}" ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} $<TARGET_FILE:${EXENAME}> VERBATIM)
endif()
endif()
# lpkg = linux package, wpkg = windows package
set(PNAME ${PROJECT_NAME}-${CODENAME}-${TIME})
if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32))