cmake update

This commit is contained in:
Markus F.X.J. Oberhumer 2024-07-19 11:13:04 +02:00
parent a7fa2f87c5
commit 0a82280f20
6 changed files with 28 additions and 8 deletions

View File

@ -513,6 +513,9 @@ jobs:
run: |
rev=$(git rev-parse --short=7 HEAD)
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV
if [[ "${{ matrix.zig_target }}" == i386-linux-gnu.2.3.4 ]]; then
echo "UPX_CONFIG_DISABLE_SHARED_LIBS=ON" >> $GITHUB_ENV # zig problem
fi
if [[ "${{ matrix.zig_target }}" == x86_64-linux-gnu.2.3.4 ]]; then
echo "NEED_GCOMPAT=1" >> $GITHUB_ENV
# TODO FIXME: problem with self-packed upx and musl+gcompat: "Not a valid dynamic program"
@ -546,6 +549,7 @@ jobs:
# INFO: it seems the zig driver does handle this automatically(??), so not really needed
if test "X$ZIG_PIC" = "X-fPIE"; then true;
echo "ZIG_FLAGS=$ZIG_FLAGS --start-no-unused-arguments -pie --end-no-unused-arguments" >> $GITHUB_ENV
echo "UPX_CONFIG_DISABLE_SHARED_LIBS=ON" >> $GITHUB_ENV # conflicts with ZIG_PIC/ZIG_FLAGS
fi
- run: set -x; zig version; zig-cc --version; zig-cxx --version
- run: zig-cc -E -x c -dM /dev/null # list predefined macros for C

View File

@ -68,7 +68,7 @@ upx_cmake_include_hook(2_init)
# clean up a few files if you accidentally try an in-source build.
upx_disallow_in_source_build()
# global settings
# global settings part 1
if(${CMAKE_VERSION} VERSION_GREATER "3.14.99" AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
cmake_policy(SET CMP0091 NEW)
@ -84,7 +84,7 @@ upx_cache_bool_vars(OFF
UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
UPX_CONFIG_DISABLE_C_STANDARD UPX_CONFIG_DISABLE_CXX_STANDARD
UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST UPX_CONFIG_DISABLE_RUN_PACKED_TEST
UPX_CONFIG_REQUIRE_THREADS
UPX_CONFIG_DISABLE_SHARED_LIBS UPX_CONFIG_REQUIRE_THREADS
)
upx_cache_bool_vars(ON UPX_CONFIG_EXPECT_THREADS)
upx_print_env_var(CC CXX)
@ -136,6 +136,11 @@ upx_set_default_build_type(Release) # default is CMAKE_BUILD_TYPE=Release
project(upx VERSION "${UPX_VERSION_STRING}" LANGUAGES C CXX)
upx_apply_build_type()
# global settings part 2
if(CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_EXECUTABLE_FORMAT MATCHES "^ELF")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
# set MSVC_FRONTEND, GNU_FRONTEND and MINGW
if(NOT DEFINED MSVC_FRONTEND AND (MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC"))
set(MSVC_FRONTEND 1)

View File

@ -97,6 +97,14 @@ function(upx_make_bool_var result_var_name var_name default_value)
set(${result_var_name} "${result}" PARENT_SCOPE) # return value
endfunction()
function(upx_unused_var) # ARGV
foreach(var_name ${ARGV})
if(DEFINED ${var_name})
set(dummy "${${var_name}}")
endif()
endforeach()
endfunction()
function(upx_print_var) # ARGV
foreach(var_name ${ARGV})
if(DEFINED ${var_name})

View File

@ -8,9 +8,11 @@
# print some info about the build configuration
#***********************************************************************
get_property(PROPERTY_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
get_property(PROPERTY_TARGET_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
# generator
upx_print_var(CMAKE_GENERATOR_TOOLSET CMAKE_GENERATOR_PLATFORM)
get_property(PROPERTY_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
upx_print_var(PROPERTY_GENERATOR_IS_MULTI_CONFIG)
# directories
@ -27,7 +29,7 @@ upx_print_var(CMAKE_VS_PLATFORM_TOOLSET CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECT
upx_print_var(CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR)
# binutils
upx_print_var(CMAKE_AR CMAKE_RANLIB)
upx_print_var(CMAKE_EXECUTABLE_FORMAT CMAKE_AR CMAKE_RANLIB)
# compilers
foreach(lang IN ITEMS ASM C CXX)
@ -43,8 +45,8 @@ foreach(lang IN ITEMS ASM C CXX)
endforeach()
# misc
upx_print_var(CMAKE_BUILD_WITH_INSTALL_RPATH)
upx_print_var(CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_POSITION_INDEPENDENT_CODE)
get_property(PROPERTY_TARGET_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
upx_print_var(PROPERTY_TARGET_SUPPORTS_SHARED_LIBS)
# shortcuts

View File

@ -287,7 +287,7 @@ void PeFile::Interval::dump() const {
**************************************************************************/
// do NOT allow --force to override reloc checks
static constexpr bool CHECK_STRICT_RELOCS = true;
static constexpr bool ALWAYS_CHECK_STRICT_RELOCS = true;
void PeFile::Reloc::RelocationBlock::reset() noexcept {
rel = nullptr; // SPAN_0
@ -375,7 +375,7 @@ bool PeFile::Reloc::readFromRelocationBlock(byte *next_rb) { // set rb
if (sob == 0 && (off == 0 && start_size_in_bytes == 8))
return false; // EOF
#endif
if (CHECK_STRICT_RELOCS) {
if (ALWAYS_CHECK_STRICT_RELOCS) {
if (sob < 8)
throwCantPack("bad reloc size_of_block %u", sob);
if (start_size_in_bytes - off < sob)
@ -456,7 +456,7 @@ void PeFile::Reloc::finish(byte *(&result_ptr), unsigned &result_size) {
unsigned pos, reloc_type;
reloc_entry_decode(entry_ptr, &pos, &reloc_type);
if (ic > 0 && pos == prev_pos) {
if (CHECK_STRICT_RELOCS)
if (ALWAYS_CHECK_STRICT_RELOCS)
throwCantPack("duplicate relocs");
else if (!opt->force)
throwCantPack("duplicate relocs (try --force)");

View File

@ -60,6 +60,7 @@
#if defined(__CYGWIN__) && defined(_WIN32)
#error "unexpected _WIN32"
#undef _WIN32
#endif
#if defined(__CYGWIN__) && defined(_WIN64)
// #error "unexpected _WIN64"