cmake: update for MinGW
This commit is contained in:
parent
33dc60df26
commit
99b795ceaa
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
|
|||||||
|
|
||||||
# compilation config options
|
# compilation config options
|
||||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
# relaxed config defaults when building from tar/zip source
|
# permissive config defaults when building from source code tarball
|
||||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." ON)
|
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." ON)
|
||||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." ON)
|
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." ON)
|
||||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." ON)
|
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." ON)
|
||||||
@ -148,10 +148,15 @@ endif()
|
|||||||
|
|
||||||
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)
|
||||||
# default sanitizer for Debug builds
|
if(CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
|
||||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
|
# avoid link errors with current MinGW-w64 versions
|
||||||
# default sanitizer for Release builds
|
# see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan
|
||||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
|
else()
|
||||||
|
# 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()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -253,27 +258,31 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
|
|||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
|
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(print_var v)
|
function(print_var)
|
||||||
if(${v})
|
foreach(v ${ARGV})
|
||||||
message(STATUS "${v} = ${${v}}")
|
if(${v})
|
||||||
endif()
|
message(STATUS "${v} = ${${v}}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
print_var(CMAKE_BUILD_TYPE)
|
print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
||||||
print_var(CMAKE_CONFIGURATION_TYPES)
|
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION)
|
||||||
print_var(CMAKE_INSTALL_PREFIX)
|
|
||||||
print_var(CMAKE_CROSSCOMPILING)
|
print_var(CMAKE_CROSSCOMPILING)
|
||||||
print_var(CMAKE_C_COMPILER_ID)
|
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
||||||
print_var(CMAKE_C_COMPILER_VERSION)
|
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
||||||
print_var(CMAKE_C_COMPILER_ARCHITECTURE_ID)
|
print_var(CMAKE_INSTALL_PREFIX)
|
||||||
print_var(CMAKE_C_PLATFORM_ID)
|
print_var(CMAKE_CONFIGURATION_TYPES)
|
||||||
print_var(CMAKE_C_COMPILER_ABI)
|
print_var(CMAKE_BUILD_TYPE)
|
||||||
print_var(CMAKE_CXX_COMPILER_ID)
|
|
||||||
print_var(CMAKE_CXX_COMPILER_VERSION)
|
|
||||||
print_var(CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
|
|
||||||
print_var(CMAKE_CXX_PLATFORM_ID)
|
|
||||||
print_var(CMAKE_CXX_COMPILER_ABI)
|
|
||||||
if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
|
if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
|
||||||
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# final extra sanity checks; in case of problems you can remove these if you know what you are doing
|
||||||
|
if(NOT ",${CMAKE_C_PLATFORM_ID}," STREQUAL ",${CMAKE_CXX_PLATFORM_ID},")
|
||||||
|
message(FATAL_ERROR "ERROR: CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID mismatch")
|
||||||
|
endif()
|
||||||
|
if(NOT ",${CMAKE_C_COMPILER_ABI}," STREQUAL ",${CMAKE_CXX_COMPILER_ABI},")
|
||||||
|
message(FATAL_ERROR "ERROR: CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI mismatch")
|
||||||
|
endif()
|
||||||
|
|
||||||
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user