From 03f64d36a04b3ba2d83f61c87a8097851933be98 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 20 Apr 2014 13:56:22 +0200 Subject: [PATCH] cotire 1.6.1 --- CMake/cotire.cmake | 44 +++++++++++++++++++++++++++++--------------- HISTORY.md | 5 +++++ MANUAL.md | 1 + src/CMakeLists.txt | 15 +++++++++++++-- src/main.cpp | 2 +- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index 3b9104c..ddfe4bf 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.0") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.1") include(CMakeParseArguments) include(ProcessorCount) @@ -856,7 +856,7 @@ function (cotire_parse_includes _language _scanOutput _ignoredIncudeDirs _honore # remove duplicate lines to speed up parsing list (REMOVE_DUPLICATES _scanOutput) list (LENGTH _scanOutput _uniqueLen) - if (COTIRE_VERBOSE) + if (COTIRE_VERBOSE OR COTIRE_DEBUG) message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes") if (_ignoredExtensions) message (STATUS "Ignored extensions: ${_ignoredExtensions}") @@ -1408,29 +1408,36 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used - # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) - get_filename_component(_prefixDir "${_prefixFile}" PATH) - get_filename_component(_prefixName "${_prefixFile}" NAME) if (_flags) # append to list - list (APPEND _flags "-Winvalid-pch" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") + list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") else() # return as a flag string - set (_flags "-Winvalid-pch -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") + set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Clang") # Clang options used # -include process include file as the first line of the primary source file + # -include-pch include precompiled header file # -Qunused-arguments don't emit warning for unused driver arguments - # -isystem treat include directory as a system directory (i.e., suppress warnings from headers) - get_filename_component(_prefixDir "${_prefixFile}" PATH) - get_filename_component(_prefixName "${_prefixFile}" NAME) - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-isystem" "${_prefixDir}" "-include" "${_prefixName}") + if (_pchFile AND NOT CMAKE_${_language}_COMPILER MATCHES "ccache") + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include-pch" "${_pchFile}") + else() + # return as a flag string + set (_flags "-Qunused-arguments -include-pch \"${_pchFile}\"") + endif() else() - # return as a flag string - set (_flags "-Qunused-arguments -isystem \"${_prefixDir}\" -include \"${_prefixName}\"") + # no precompiled header, force inclusion of prefix header + # ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1570,6 +1577,13 @@ function (cotire_check_precompiled_header_support _language _targetSourceDir _ta else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() + if (CMAKE_${_language}_COMPILER MATCHES "ccache") + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to time_macros." + PARENT_SCOPE) + endif() + endif() if (APPLE) # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) if (CMAKE_CONFIGURATION_TYPES) diff --git a/HISTORY.md b/HISTORY.md index 49bfa00..caed07f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.6.1 (2014-04-20) + +* fixed bug where precompiled headers did not work with Clang (thanks to nh2 for reporting). +* when using ccache, require that environment variable `CCACHE_SLOPPINESS` is set to `time_macros`. + ## 1.6.0 (2014-03-16) * suppress compiler warnings from precompiled headers. diff --git a/MANUAL.md b/MANUAL.md index 8f6d24d..310057e 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -539,6 +539,7 @@ enabled in the following way upon configuring the project: $ export CC="/usr/local/bin/ccache /usr/bin/gcc" $ export CXX="/usr/local/bin/ccache /usr/bin/g++" + $ export CCACHE_SLOPPINESS=time_macros $ cmake .. Note that with ccache in order for precompiled headers to work properly, it is necessary to set diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce6c105..980541e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,8 +2,19 @@ add_executable(example main.cpp example.cpp log.cpp log.h example.h) -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall") +# enable warnings +if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set_target_properties(example PROPERTIES COMPILE_FLAGS "/Wall") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Weverything") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -Wextra") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") + if (UNIX) + set_target_properties(example PROPERTIES COMPILE_FLAGS "-w5") + elseif (WIN32) + set_target_properties(example PROPERTIES COMPILE_FLAGS "/W5") + endif() endif() cotire(example) diff --git a/src/main.cpp b/src/main.cpp index 6c7aadc..2ea1af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include "example.h" #include "log.h" -int main(int argc, char** argv) +int main() { std::string msg = example::get_message(); logging::info(msg);