From 72f3e9b25a3db297334a7e22cb825523035850de Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Tue, 3 Jan 2023 15:11:11 +0100 Subject: [PATCH] all: require C++17 --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 8 ++++---- Makefile | 2 ++ compile_flags.txt | 1 + src/conf.h | 8 ++------ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9bad471..9a7cb6c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,7 +286,7 @@ jobs: set s=%H%\src cat .GITREV.txt set /p GITREV=<.GITREV.txt - cl -MT -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -I%H%\vendor -Feupx.exe %s%\*.cpp %s%\util\*.cpp %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib /link setargv.obj + cl -std:c++17 -Zc:__cplusplus -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -I%H%\vendor -Feupx.exe %s%\*.cpp %s%\util\*.cpp %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib /link setargv.obj - name: 'Make artifact' shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c70006..eedf5a61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8 FATAL_ERROR) # compilation config options if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") @@ -110,8 +110,8 @@ set_property(TARGET upx_vendor_zlib PROPERTY C_STANDARD 11) file(GLOB upx_SOURCES "src/*.cpp" "src/util/*.cpp") list(SORT upx_SOURCES) add_executable(upx ${upx_SOURCES}) -#target_compile_features(upx PRIVATE cxx_std_14) -set_property(TARGET upx PROPERTY CXX_STANDARD 14) +#target_compile_features(upx PRIVATE cxx_std_17) +set_property(TARGET upx PROPERTY CXX_STANDARD 17) target_link_libraries(upx upx_vendor_ucl upx_vendor_zlib) if(UPX_CONFIG_DISABLE_WERROR) @@ -190,7 +190,7 @@ if(GITREV_SHORT) endif() upx_sanitize_target(${t}) if(MSVC) - target_compile_options(${t} PRIVATE -EHsc -J -W4 ${warn_WX}) + target_compile_options(${t} PRIVATE -Zc:__cplusplus -EHsc -J -W4 ${warn_WX}) else() target_compile_options(${t} PRIVATE -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith diff --git a/Makefile b/Makefile index 71635db4..f0ec3b05 100644 --- a/Makefile +++ b/Makefile @@ -129,3 +129,5 @@ endif ifeq ($(wildcard ./vendor/zlib/crc32.c),) $(error ERROR: missing git submodule; run 'git submodule update --init') endif + +.NOTPARALLEL: # top-level Makefile is sequential, but actual builds use "cmake --parallel" diff --git a/compile_flags.txt b/compile_flags.txt index ed6dbff7..486ef41c 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,3 +1,4 @@ +-std=gnu++17 -Ivendor -fno-strict-aliasing -fno-strict-overflow diff --git a/src/conf.h b/src/conf.h index 8bc10e69..00b0b9b9 100644 --- a/src/conf.h +++ b/src/conf.h @@ -29,12 +29,8 @@ #ifndef UPX_CONF_H__ #define UPX_CONF_H__ 1 -#if defined(__cplusplus) -# if (__cplusplus >= 201402L) -# elif defined(_MSC_VER) && defined(_MSVC_LANG) && (_MSVC_LANG+0 >= 201402L) -# else -# error "C++ 14 is required" -# endif +#if !(__cplusplus+0 >= 201703L) +# error "C++ 17 is required" #endif #include "version.h"