diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60e7f2fe..b8a49568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,11 @@ name: 'CI' on: [push, workflow_dispatch] env: + CMAKE_REQUIRED_QUIET: 0 DEBIAN_FRONTEND: noninteractive UPX_CMAKE_BUILD_FLAGS: --verbose - # 2023-07-05 - ZIG_DIST_VERSION: 0.11.0-dev.3937+78eb3c561 + # 2023-07-15 + ZIG_DIST_VERSION: 0.11.0-dev.4002+7dd1cf26f jobs: job-rebuild-and-verify-stubs: diff --git a/.github/workflows/misc-spell-check.yml b/.github/workflows/misc-spell-check.yml index a39884e5..3ee213c4 100644 --- a/.github/workflows/misc-spell-check.yml +++ b/.github/workflows/misc-spell-check.yml @@ -4,6 +4,8 @@ name: 'Misc - Spell check' on: workflow_dispatch: +env: + DEBIAN_FRONTEND: noninteractive jobs: job-spell-check: name: 'Spell check' diff --git a/.github/workflows/static-analyzer-clang-analyzer.yml b/.github/workflows/static-analyzer-clang-analyzer.yml index bac9a868..56262a1d 100644 --- a/.github/workflows/static-analyzer-clang-analyzer.yml +++ b/.github/workflows/static-analyzer-clang-analyzer.yml @@ -1,9 +1,12 @@ # Copyright (C) Markus Franz Xaver Johannes Oberhumer -name: 'Static Analyzer - clang-analyzer' +name: 'Static Analyzer - clang-analyzer' on: schedule: [cron: '10 5 * * 3'] # run weekly Wednesday 05:10 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-analyze-clang-analyzer: # uses cmake + make diff --git a/.github/workflows/static-analyzer-clang-tidy.yml b/.github/workflows/static-analyzer-clang-tidy.yml index 4ae52186..e89279fd 100644 --- a/.github/workflows/static-analyzer-clang-tidy.yml +++ b/.github/workflows/static-analyzer-clang-tidy.yml @@ -1,9 +1,12 @@ # Copyright (C) Markus Franz Xaver Johannes Oberhumer -name: 'Static Analyzer - clang-tidy' +name: 'Static Analyzer - clang-tidy' on: schedule: [cron: '30 5 * * 3'] # run weekly Wednesday 05:30 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-analyze-clang-tidy: # uses cmake + make diff --git a/.github/workflows/static-analyzer-codeql.yml b/.github/workflows/static-analyzer-codeql.yml index 13679861..f2db4095 100644 --- a/.github/workflows/static-analyzer-codeql.yml +++ b/.github/workflows/static-analyzer-codeql.yml @@ -1,9 +1,12 @@ # Copyright (C) Markus Franz Xaver Johannes Oberhumer -name: 'Static Analyzer - CodeQL' +name: 'Static Analyzer - CodeQL' on: schedule: [cron: '50 5 * * 3'] # run weekly Wednesday 05:50 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-analyze-codeql: diff --git a/.github/workflows/test-alpine-linux.yml b/.github/workflows/test-alpine-linux.yml index be5d3b25..09c6a2a0 100644 --- a/.github/workflows/test-alpine-linux.yml +++ b/.github/workflows/test-alpine-linux.yml @@ -5,6 +5,9 @@ name: 'Test - Minimal Alpine build' on: [workflow_dispatch] +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-alpine-clang: # uses cmake + make diff --git a/.github/workflows/test-cmake-default.yml b/.github/workflows/test-cmake-default.yml index 7574f255..bf6af485 100644 --- a/.github/workflows/test-cmake-default.yml +++ b/.github/workflows/test-cmake-default.yml @@ -2,8 +2,8 @@ name: 'Test - CMake default build type' on: [workflow_dispatch] - env: + CMAKE_REQUIRED_QUIET: 0 DEBIAN_FRONTEND: noninteractive jobs: diff --git a/.github/workflows/weekly-ci-alpine-linux.yml b/.github/workflows/weekly-ci-alpine-linux.yml index 4cb88f5a..90f70922 100644 --- a/.github/workflows/weekly-ci-alpine-linux.yml +++ b/.github/workflows/weekly-ci-alpine-linux.yml @@ -9,10 +9,12 @@ # matches our minimal build requirements name: 'Weekly CI - Alpine Linux' - on: schedule: [cron: '05 4 * * 3'] # run weekly Wednesday 04:05 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-alpine-cmake: # uses cmake + make diff --git a/.github/workflows/weekly-ci-cmake-macos-xcode.yml b/.github/workflows/weekly-ci-cmake-macos-xcode.yml index 5d5ad7d4..84353195 100644 --- a/.github/workflows/weekly-ci-cmake-macos-xcode.yml +++ b/.github/workflows/weekly-ci-cmake-macos-xcode.yml @@ -2,10 +2,12 @@ # build with 'cmake -G Xcode' name: 'Weekly CI - cmake macOS Xcode' - on: schedule: [cron: '20 4 * * 3'] # run weekly Wednesday 04:20 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-cmake-macos-xcode: # uses cmake + xcodebuild diff --git a/.github/workflows/weekly-ci-cmake-windows-nmake.yml b/.github/workflows/weekly-ci-cmake-windows-nmake.yml index ce953d7e..40cd0e01 100644 --- a/.github/workflows/weekly-ci-cmake-windows-nmake.yml +++ b/.github/workflows/weekly-ci-cmake-windows-nmake.yml @@ -2,10 +2,12 @@ # build with 'cmake -G "NMake Makefiles"' name: 'Weekly CI - cmake Windows NMake' - on: schedule: [cron: '30 4 * * 3'] # run weekly Wednesday 04:30 UTC workflow_dispatch: +env: + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive jobs: job-cmake-windows-nmake: # uses cmake + nmake diff --git a/.github/workflows/weekly-ci-zigcc.yml b/.github/workflows/weekly-ci-zigcc.yml index c9acfa0d..b8482ecb 100644 --- a/.github/workflows/weekly-ci-zigcc.yml +++ b/.github/workflows/weekly-ci-zigcc.yml @@ -2,14 +2,14 @@ # build with "zig cc"; see https://ziglang.org/download/ name: 'Weekly CI - zigcc' - on: schedule: [cron: '40 4 * * 3'] # run weekly Wednesday 04:40 UTC workflow_dispatch: - env: - # 2023-07-05 - ZIG_DIST_VERSION: 0.11.0-dev.3937+78eb3c561 + CMAKE_REQUIRED_QUIET: 0 + DEBIAN_FRONTEND: noninteractive + # 2023-07-15 + ZIG_DIST_VERSION: 0.11.0-dev.4002+7dd1cf26f jobs: job-linux-zigcc: # uses cmake + make diff --git a/CMakeLists.txt b/CMakeLists.txt index cb925232..83340692 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,9 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.14.7") endif() if(NOT DEFINED CMAKE_REQUIRED_QUIET) set(CMAKE_REQUIRED_QUIET ON) + if("$ENV{CMAKE_REQUIRED_QUIET}" MATCHES "^(0|1|OFF|ON)$") + set(CMAKE_REQUIRED_QUIET "$ENV{CMAKE_REQUIRED_QUIET}") + endif() endif() # determine Git revision @@ -125,7 +128,7 @@ endif() # set MSVC_FRONTEND set(MSVC_FRONTEND 0) -if(MSVC OR ",${CMAKE_C_COMPILER_FRONTEND_VARIANT}," STREQUAL ",MSVC,") +if(MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC") set(MSVC_FRONTEND 1) endif() @@ -165,14 +168,13 @@ function(upx_add_definitions) endforeach() endfunction() -if(NOT MSVC) +if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC") # use -O2 instead of -O3 to reduce code size string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" a "${CMAKE_C_FLAGS_RELEASE}") string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" b "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_RELEASE "${a}" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE) set(CMAKE_CXX_FLAGS_RELEASE "${b}" CACHE STRING "Flags used by the CXX compiler during RELEASE builds." FORCE) endif() - if(MSVC_FRONTEND) # disable silly warnings about using "deprecated" POSIX functions like fopen() add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) @@ -181,19 +183,18 @@ if(MSVC_FRONTEND) add_definitions(-D_CRT_SECURE_NO_WARNINGS) # use -funsigned-char; set __cplusplus according to selected C++ standard add_definitions(-J -Zc:__cplusplus) - if(CMAKE_C_COMPILER_ID MATCHES "MSVC") + if(CMAKE_C_COMPILER_ID MATCHES "^MSVC") upx_add_definitions(-Zc:preprocessor) # use new preprocessor - elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") - upx_add_definitions(-clang:-fno-strict-aliasing -clang:-fno-strict-overflow) endif() -else() +endif() +if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC") # protect against security threats caused by misguided compiler "optimizations" upx_add_definitions(-fno-delete-null-pointer-checks -fno-lifetime-dse) upx_add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char) # disable overambitious auto-vectorization until this actually gains something upx_add_definitions(-fno-tree-vectorize) # disable annoying clang warnings which get added by the macOS Xcode cmake generator - if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_GENERATOR STREQUAL "Xcode") + if(CMAKE_GENERATOR MATCHES "Xcode") upx_add_definitions(-Wno-shorten-64-to-32) endif() endif() @@ -455,7 +456,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt") include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt") endif() -print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION) +print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR) 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)