mirror of https://github.com/upx/upx.git
cmake: compile compression libs with -O2 even in Debug mode
This commit is contained in:
parent
cc994326a0
commit
aa050e0001
|
@ -159,9 +159,18 @@ else()
|
||||||
add_definitions(-fno-tree-vectorize)
|
add_definitions(-fno-tree-vectorize)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# compile a target with -O2 in Debug mode
|
||||||
|
function(upx_compile_target_debug_with_O2 t)
|
||||||
|
if(MSVC)
|
||||||
|
# msvc uses some Debug compile options like -RTC1 that are incompatible with -O2
|
||||||
|
else()
|
||||||
|
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-O2>)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(upx_sanitize_target t)
|
function(upx_sanitize_target t)
|
||||||
if(NOT UPX_CONFIG_DISABLE_SANITIZE AND NOT MSVC)
|
if(NOT UPX_CONFIG_DISABLE_SANITIZE AND NOT MSVC)
|
||||||
if(CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
|
if(CMAKE_C_PLATFORM_ID MATCHES "^MinGW" OR MINGW OR CYGWIN)
|
||||||
# avoid link errors with current MinGW-w64 versions
|
# avoid link errors with current MinGW-w64 versions
|
||||||
# see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan
|
# see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan
|
||||||
else()
|
else()
|
||||||
|
@ -175,6 +184,7 @@ endfunction()
|
||||||
|
|
||||||
set(t upx_vendor_ucl)
|
set(t upx_vendor_ucl)
|
||||||
target_include_directories(${t} PRIVATE vendor/ucl/include vendor/ucl)
|
target_include_directories(${t} PRIVATE vendor/ucl/include vendor/ucl)
|
||||||
|
upx_compile_target_debug_with_O2(${t})
|
||||||
upx_sanitize_target(${t})
|
upx_sanitize_target(${t})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${t} PRIVATE -J -W4 ${warn_WX})
|
target_compile_options(${t} PRIVATE -J -W4 ${warn_WX})
|
||||||
|
@ -183,6 +193,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(t upx_vendor_zlib)
|
set(t upx_vendor_zlib)
|
||||||
|
upx_compile_target_debug_with_O2(${t})
|
||||||
upx_sanitize_target(${t})
|
upx_sanitize_target(${t})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${t} PRIVATE -DHAVE_STDARG_H -DHAVE_VSNPRINTF -J -W3 ${warn_WX})
|
target_compile_options(${t} PRIVATE -DHAVE_STDARG_H -DHAVE_VSNPRINTF -J -W3 ${warn_WX})
|
||||||
|
@ -194,6 +205,7 @@ endif()
|
||||||
|
|
||||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||||
set(t upx_vendor_zstd)
|
set(t upx_vendor_zstd)
|
||||||
|
upx_compile_target_debug_with_O2(${t})
|
||||||
upx_sanitize_target(${t})
|
upx_sanitize_target(${t})
|
||||||
target_compile_options(${t} PRIVATE -DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM)
|
target_compile_options(${t} PRIVATE -DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -212,6 +224,7 @@ if(GITREV_SHORT)
|
||||||
target_compile_definitions(${t} PRIVATE UPX_VERSION_GIT_DESCRIBE="${GIT_DESCRIBE}")
|
target_compile_definitions(${t} PRIVATE UPX_VERSION_GIT_DESCRIBE="${GIT_DESCRIBE}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
#upx_compile_target_debug_with_O2(${t})
|
||||||
upx_sanitize_target(${t})
|
upx_sanitize_target(${t})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${t} PRIVATE -Zc:__cplusplus -EHsc -J -W4 ${warn_WX})
|
target_compile_options(${t} PRIVATE -Zc:__cplusplus -EHsc -J -W4 ${warn_WX})
|
||||||
|
|
|
@ -44,8 +44,8 @@ Short overview
|
||||||
Tools needed to build/modify the UPX sources
|
Tools needed to build/modify the UPX sources
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
- A C++ compiler that supports C++ 17: clang 5.0, gcc 8.0 or msvc 2019 16.11
|
- A C++ compiler that supports C++ 17: clang-5, gcc-8 or msvc-2019 16.11
|
||||||
(older or other compilers may work, use at your own risk)
|
(older or other compilers may work but are unsupported, use at your own risk)
|
||||||
|
|
||||||
- GNU make
|
- GNU make
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue