From aaf3f75990200be381a0267a4b041fa5222cd7d1 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sun, 25 Jun 2023 01:55:06 +0200 Subject: [PATCH] CI and cmake updates --- .github/workflows/ci.yml | 4 +- .../workflows/weekly-ci-macos-cmake-xcode.yml | 2 +- .../weekly-ci-windows-cmake-nmake.yml | 51 +++++++++++++++++++ .github/workflows/weekly-ci-zigcc.yml | 6 +-- CMakeLists.txt | 42 +++++++++------ README.SRC | 2 +- 6 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/weekly-ci-windows-cmake-nmake.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 940a0b4c..77f405aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,8 +11,8 @@ on: [push, workflow_dispatch] env: DEBIAN_FRONTEND: noninteractive UPX_CMAKE_BUILD_FLAGS: --verbose - # 2023-06-23 - ZIG_DIST_VERSION: 0.11.0-dev.3777+64f0059cd + # 2023-06-24 + ZIG_DIST_VERSION: 0.11.0-dev.3797+d82ab4fd8 jobs: job-rebuild-and-verify-stubs: diff --git a/.github/workflows/weekly-ci-macos-cmake-xcode.yml b/.github/workflows/weekly-ci-macos-cmake-xcode.yml index 1e4e9608..87dcddbb 100644 --- a/.github/workflows/weekly-ci-macos-cmake-xcode.yml +++ b/.github/workflows/weekly-ci-macos-cmake-xcode.yml @@ -1,4 +1,4 @@ -# build with "cmake -G Xcode" +# build with 'cmake -G Xcode' name: 'Weekly CI - macOS cmake Xcode' diff --git a/.github/workflows/weekly-ci-windows-cmake-nmake.yml b/.github/workflows/weekly-ci-windows-cmake-nmake.yml new file mode 100644 index 00000000..7a3bd7f2 --- /dev/null +++ b/.github/workflows/weekly-ci-windows-cmake-nmake.yml @@ -0,0 +1,51 @@ +# build with 'cmake -G "NMake Makefiles"' + +name: 'Weekly CI - Windows cmake NMake' + +on: + schedule: [cron: '30 4 * * 3'] # run weekly Wednesday 04:30 UTC + workflow_dispatch: + +jobs: + job-windows-cmake-nmake: + name: ${{ format('{0} {1}', matrix.os, matrix.arch) }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - { os: windows-2019, vsversion: 2019, arch: amd64 } + - { os: windows-2019, vsversion: 2019, arch: amd64_arm64 } + - { os: windows-2019, vsversion: 2019, arch: amd64_x86 } + - { os: windows-2022, vsversion: 2022, arch: amd64 } + - { os: windows-2022, vsversion: 2022, arch: amd64_arm64 } + - { os: windows-2022, vsversion: 2022, arch: amd64_x86 } + steps: + - name: 'Check out code' + uses: actions/checkout@v3 + with: { submodules: true } + - name: 'Set up Developer Command Prompt' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + vsversion: ${{ matrix.vsversion }} + - name: 'Build cmake NMake Debug' + shell: cmd + run: | + cmake -S . -B build/debug -G "NMake Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug + cd build/debug + nmake + dir *.exe + - name: 'Build cmake NMake Release' + shell: cmd + run: | + cmake -S . -B build/release -G "NMake Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON + cd build/release + nmake + dir *.exe + - name: 'Run basic tests' + if: ${{ matrix.arch != 'amd64_arm64' }} + shell: cmd + run: | + ctest --test-dir build/debug + ctest --test-dir build/release diff --git a/.github/workflows/weekly-ci-zigcc.yml b/.github/workflows/weekly-ci-zigcc.yml index 0ca784b1..e6f0728e 100644 --- a/.github/workflows/weekly-ci-zigcc.yml +++ b/.github/workflows/weekly-ci-zigcc.yml @@ -3,12 +3,12 @@ name: 'Weekly CI - zigcc' on: - schedule: [cron: '30 4 * * 3'] # run weekly Wednesday 04:30 UTC + schedule: [cron: '40 4 * * 3'] # run weekly Wednesday 04:40 UTC workflow_dispatch: env: - # 2023-06-23 - ZIG_DIST_VERSION: 0.11.0-dev.3777+64f0059cd + # 2023-06-24 + ZIG_DIST_VERSION: 0.11.0-dev.3797+d82ab4fd8 jobs: job-linux-zigcc: diff --git a/CMakeLists.txt b/CMakeLists.txt index 39788c75..82c30db6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,19 @@ # -# UPX CMake file; see https://cmake.org/ +# UPX "CMake" build file; see https://cmake.org/ # Copyright (C) Markus Franz Xaver Johannes Oberhumer # -# CMake version check; using a somewhat current CMake version is highly recommended -if(NOT DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION) - cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) # needed for CXX_STANDARD 17 -else() - cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR) -endif() # Build requirements: -# A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019 16.11 +# A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11 # (older or other compilers may work but are unsupported, use at your own risk) +# CMake version check; using a somewhat current CMake version is highly recommended +if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION) + cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR) +else() + cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17 +endif() + # compilation config options if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") # permissive config defaults when building from source code tarball @@ -51,7 +52,10 @@ endif() set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") +if(${CMAKE_VERSION} VERSION_GREATER "3.14.7") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + cmake_policy(SET CMP0091 NEW) +endif() # determine Git revision set(GITREV_SHORT "") @@ -95,11 +99,16 @@ else() message(STATUS "UPX_VERSION_GITREV: not set") endif() -# CMake init -project(upx VERSION 4.0.2 LANGUAGES C CXX) - -# set default build type to "Release" +# set the default build type to "Release" get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT is_multi_config AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) +endif() + +# CMake init +project(upx VERSION 4.1.0 LANGUAGES C CXX) + +# set the default multi-config build type to "Release" if(is_multi_config) set(c "${CMAKE_CONFIGURATION_TYPES}") list(INSERT c 0 "Release") @@ -109,8 +118,6 @@ if(is_multi_config) endif() list(REMOVE_DUPLICATES c) set(CMAKE_CONFIGURATION_TYPES "${c}" CACHE STRING "List of supported configuration types." FORCE) -elseif(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) endif() set(MSVC_FRONTEND 0) @@ -122,6 +129,7 @@ endif() # targets #*********************************************************************** +# internal settings set(UPX_CONFIG_DISABLE_THREADS ON) # multithreading is currently not used; maybe in UPX version 5 set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 5 @@ -254,7 +262,9 @@ function(upx_sanitize_target) # default sanitizer for Debug builds target_compile_options(${t} PRIVATE $<$:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>) # default sanitizer for Release builds + target_compile_options(${t} PRIVATE $<$:-fstack-protector>) target_compile_options(${t} PRIVATE $<$:-fstack-protector>) + target_compile_options(${t} PRIVATE $<$:-fstack-protector>) endif() endforeach() endfunction() @@ -417,7 +427,7 @@ function(print_var) endif() endforeach() endfunction() -print_var(CMAKE_VERSION) +print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION) if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO) print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION) print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING) diff --git a/README.SRC b/README.SRC index eb758101..d2df66e5 100644 --- a/README.SRC +++ b/README.SRC @@ -44,7 +44,7 @@ Short overview Tools needed to build/modify the UPX sources -------------------------------------------- - - A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019 16.11 + - A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11 (older or other compilers may work but are unsupported, use at your own risk) - GNU make