From: Joel Rosdahl Date: Sun, 30 May 2021 18:40:35 +0000 (+0200) Subject: Include config.h via command line instead of via system.h X-Git-Tag: v4.4~213 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a57f70eda32e99221de56f5499079b4f00dc2bc5;p=thirdparty%2Fccache.git Include config.h via command line instead of via system.h This makes the definitions in config.h available to all source code, including third_party_lib. It’s also a first step towards not having to include system.hpp and its libc headers from all files. --- diff --git a/cmake/StandardSettings.cmake b/cmake/StandardSettings.cmake index a0f0189c7..46854f3c0 100644 --- a/cmake/StandardSettings.cmake +++ b/cmake/StandardSettings.cmake @@ -3,10 +3,12 @@ add_library(standard_settings INTERFACE) -# Not supported in CMake 3.4: target_compile_features(project_options INTERFACE -# c_std_11 cxx_std_11) - if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$") + target_compile_options( + standard_settings + INTERFACE -include ${CMAKE_BINARY_DIR}/config.h + ) + option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE) if(ENABLE_COVERAGE) target_compile_options(standard_settings INTERFACE --coverage -O0 -g) @@ -50,5 +52,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$") include(StdAtomic) elseif(MSVC) - target_compile_options(standard_settings INTERFACE /std:c++latest /Zc:preprocessor /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS) + target_compile_options(standard_settings INTERFACE /FI ${CMAKE_BINARY_DIR}/config.h) + + target_compile_options( + standard_settings + INTERFACE /std:c++latest /Zc:preprocessor /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS + ) endif() diff --git a/cmake/config.h.in b/cmake/config.h.in index d10e16417..fe99e16d8 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -6,6 +6,11 @@ # endif #endif +#ifdef __MINGW32__ +# define __USE_MINGW_ANSI_STDIO 1 +# define __STDC_FORMAT_MACROS 1 +#endif + // For example for vasprintf under i686-w64-mingw32-g++-posix. The later // definition of _XOPEN_SOURCE disables certain features on Linux, so we need // _GNU_SOURCE to re-enable them (makedev, tm_zone). diff --git a/src/system.hpp b/src/system.hpp index fa4bbf3e3..b58119e35 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2020 Joel Rosdahl and other contributors +// Copyright (C) 2010-2021 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -18,13 +18,6 @@ #pragma once -#ifdef __MINGW32__ -# define __USE_MINGW_ANSI_STDIO 1 -# define __STDC_FORMAT_MACROS 1 -#endif - -#include "config.h" - #ifdef HAVE_SYS_FILE_H # include #endif diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt index 14dce9216..54cd3b256 100644 --- a/src/third_party/CMakeLists.txt +++ b/src/third_party/CMakeLists.txt @@ -10,12 +10,6 @@ if(WIN32) target_sources(third_party_lib PRIVATE win32/mktemp.c) endif () -if(MSVC) - target_compile_options(third_party_lib PRIVATE /FI ${CMAKE_BINARY_DIR}/config.h) -else() - target_compile_options(third_party_lib PRIVATE -include ${CMAKE_BINARY_DIR}/config.h) -endif() - if(ENABLE_TRACING) target_sources(third_party_lib PRIVATE minitrace.c) endif()