From 7b6e2165ba507512af742ed55488a9bd9af43c50 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 11 Jun 2022 16:11:06 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c831b..bb598e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} $ VERBATIM) + endif() +endif() + # lpkg = linux package, wpkg = windows package set(PNAME ${PROJECT_NAME}-${CODENAME}-${TIME}) if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32))