all: misc cleanups
This commit is contained in:
+17
-6
@@ -19,6 +19,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if(",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_BINARY_DIR},")
|
||||
message(FATAL_ERROR "ERROR: In-source builds are not allowed, please use an extra build dir.")
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# determine git revision
|
||||
set(GITREV_SHORT "")
|
||||
@@ -61,6 +63,8 @@ if(GITREV_SHORT)
|
||||
if(GIT_DESCRIBE)
|
||||
message(STATUS "UPX_VERSION_GIT_DESCRIBE = \"${GIT_DESCRIBE}\"")
|
||||
endif()
|
||||
elseif(UPX_CONFIG_DISABLE_GITREV)
|
||||
message(STATUS "UPX_VERSION_GITREV: disabled")
|
||||
else()
|
||||
message(STATUS "UPX_VERSION_GITREV: not set")
|
||||
endif()
|
||||
@@ -99,6 +103,7 @@ set_property(TARGET upx_vendor_zlib PROPERTY C_STANDARD 11)
|
||||
file(GLOB upx_SOURCES "src/*.cpp" "src/util/*.cpp")
|
||||
list(SORT upx_SOURCES)
|
||||
add_executable(upx ${upx_SOURCES})
|
||||
#target_compile_features(upx PRIVATE cxx_std_14)
|
||||
set_property(TARGET upx PROPERTY CXX_STANDARD 14)
|
||||
target_link_libraries(upx upx_vendor_ucl upx_vendor_zlib)
|
||||
|
||||
@@ -134,8 +139,18 @@ else()
|
||||
add_definitions(-fno-tree-vectorize)
|
||||
endif()
|
||||
|
||||
function(upx_sanitize_target t)
|
||||
if(NOT UPX_CONFIG_DISABLE_SANITIZE AND NOT MSVC)
|
||||
# default sanitizer for Debug builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
|
||||
# default sanitizer for Release builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(t upx_vendor_ucl)
|
||||
target_include_directories(${t} PRIVATE vendor/ucl/include vendor/ucl)
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC)
|
||||
target_compile_options(${t} PRIVATE -J -W4 ${warn_WX})
|
||||
else()
|
||||
@@ -143,6 +158,7 @@ else()
|
||||
endif()
|
||||
|
||||
set(t upx_vendor_zlib)
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC)
|
||||
target_compile_options(${t} PRIVATE -DHAVE_STDARG_H -DHAVE_VSNPRINTF -J -W3 ${warn_WX})
|
||||
else()
|
||||
@@ -160,12 +176,7 @@ if(GITREV_SHORT)
|
||||
target_compile_definitions(${t} PRIVATE UPX_VERSION_GIT_DESCRIBE="${GIT_DESCRIBE}")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_SANITIZE AND NOT MSVC)
|
||||
# default sanitizer for Debug builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
|
||||
# default sanitizer for Release builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
|
||||
endif()
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC)
|
||||
target_compile_options(${t} PRIVATE -EHsc -J -W4 ${warn_WX})
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user