cmake: default to relaxed options when building from source tarball
This commit is contained in:
+21
-14
@@ -1,11 +1,22 @@
|
|||||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
|
||||||
|
|
||||||
# compilation config options
|
# compilation config options
|
||||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info.")
|
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options.")
|
# relaxed config defaults when building from tar/zip source
|
||||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option.")
|
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." ON)
|
||||||
# test config options
|
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." ON)
|
||||||
option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself") # see below
|
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." ON)
|
||||||
|
else()
|
||||||
|
# strict config defaults for devel builds
|
||||||
|
message(STATUS "upx info: strict config defaults enabled")
|
||||||
|
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." OFF)
|
||||||
|
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." OFF)
|
||||||
|
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# test config options (see below)
|
||||||
|
# NOTE: self-pack test can only work if the host executable format is supported by UPX!
|
||||||
|
option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" OFF)
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# init
|
# init
|
||||||
@@ -29,11 +40,9 @@ set(GIT_DESCRIBE "")
|
|||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(GIT_FOUND AND NOT UPX_CONFIG_DISABLE_GITREV)
|
if(GIT_FOUND AND NOT UPX_CONFIG_DISABLE_GITREV)
|
||||||
execute_process(
|
execute_process(
|
||||||
RESULT_VARIABLE result
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
|
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
|
||||||
ERROR_QUIET
|
RESULT_VARIABLE result ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_VARIABLE GITREV_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE GITREV_SHORT
|
|
||||||
)
|
)
|
||||||
string(LENGTH "${GITREV_SHORT}" l)
|
string(LENGTH "${GITREV_SHORT}" l)
|
||||||
if(${result} EQUAL 0 AND ${l} EQUAL 12)
|
if(${result} EQUAL 0 AND ${l} EQUAL 12)
|
||||||
@@ -45,11 +54,9 @@ if(GIT_FOUND AND NOT UPX_CONFIG_DISABLE_GITREV)
|
|||||||
set(GITREV_SHORT "")
|
set(GITREV_SHORT "")
|
||||||
endif()
|
endif()
|
||||||
execute_process(
|
execute_process(
|
||||||
RESULT_VARIABLE result
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" describe --match "v*.*.*" --tags --dirty
|
COMMAND "${GIT_EXECUTABLE}" describe --match "v*.*.*" --tags --dirty
|
||||||
ERROR_QUIET
|
RESULT_VARIABLE result ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE GIT_DESCRIBE
|
|
||||||
)
|
)
|
||||||
if(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$")
|
if(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$")
|
||||||
set(GIT_DESCRIBE "${CMAKE_MATCH_1}-devel.${CMAKE_MATCH_2}+git-${CMAKE_MATCH_3}")
|
set(GIT_DESCRIBE "${CMAKE_MATCH_1}-devel.${CMAKE_MATCH_2}+git-${CMAKE_MATCH_3}")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
||||||
#
|
#
|
||||||
|
|
||||||
# NOTE: if you only have CMake 3.10 then you can invoke cmake manually like this:
|
# NOTE: if you only have an older CMake 3.x then you can invoke cmake manually like this:
|
||||||
# mkdir -p build/release
|
# mkdir -p build/release
|
||||||
# cd build/release
|
# cd build/release
|
||||||
# cmake ../..
|
# cmake ../..
|
||||||
|
|||||||
Reference in New Issue
Block a user