Fixes #884.
-cmake_minimum_required(VERSION 3.4.3)
-
-if(POLICY CMP0067)
- cmake_policy(SET CMP0067 NEW)
-endif()
+cmake_minimum_required(VERSION 3.10)
project(ccache LANGUAGES C CXX)
if(MSVC)
include(CIBuildType)
include(DefaultBuildType)
-if(NOT ${CMAKE_VERSION} VERSION_LESS "3.9")
- cmake_policy(SET CMP0069 NEW)
- option(ENABLE_IPO "Enable interprocedural (link time, LTO) optimization" OFF)
- if(ENABLE_IPO)
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
- endif()
+option(ENABLE_IPO "Enable interprocedural (link time, LTO) optimization" OFF)
+if(ENABLE_IPO)
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
#
# Note: This is part of CMakeLists.txt file, not to be confused with
# CPackConfig.cmake.
-if(${CMAKE_VERSION} VERSION_LESS "3.9")
- set(CPACK_PACKAGE_DESCRIPTION "${CMAKE_PROJECT_DESCRIPTION}")
-endif()
-
# From CcacheVersion.cmake.
set(CPACK_PACKAGE_VERSION ${CCACHE_VERSION})
option(ENABLE_CPPCHECK "Enable static analysis with Cppcheck" OFF)
if(ENABLE_CPPCHECK)
- if(${CMAKE_VERSION} VERSION_LESS "3.10")
- message(WARNING "Cppcheck requires CMake 3.10")
+ find_program(CPPCHECK_EXE cppcheck)
+ mark_as_advanced(CPPCHECK_EXE) # Don't show in CMake UIs
+ if(CPPCHECK_EXE)
+ set(CMAKE_CXX_CPPCHECK
+ ${CPPCHECK_EXE}
+ --suppressions-list=${CMAKE_SOURCE_DIR}/misc/cppcheck-suppressions.txt
+ --inline-suppr
+ -q
+ --enable=all
+ --force
+ --std=c++14
+ -I ${CMAKE_SOURCE_DIR}
+ --template="cppcheck: warning: {id}:{file}:{line}: {message}"
+ -i src/third_party)
else()
- find_program(CPPCHECK_EXE cppcheck)
- mark_as_advanced(CPPCHECK_EXE) # Don't show in CMake UIs
- if(CPPCHECK_EXE)
- set(CMAKE_CXX_CPPCHECK
- ${CPPCHECK_EXE}
- --suppressions-list=${CMAKE_SOURCE_DIR}/misc/cppcheck-suppressions.txt
- --inline-suppr
- -q
- --enable=all
- --force
- --std=c++14
- -I ${CMAKE_SOURCE_DIR}
- --template="cppcheck: warning: {id}:{file}:{line}: {message}"
- -i src/third_party)
- else()
- message(WARNING "Cppcheck requested but executable not found")
- endif()
+ message(WARNING "Cppcheck requested but executable not found")
endif()
endif()
option(ENABLE_CLANG_TIDY "Enable static analysis with Clang-Tidy" OFF)
if(ENABLE_CLANG_TIDY)
- if(${CMAKE_VERSION} VERSION_LESS "3.6")
- message(WARNING "Clang-Tidy requires CMake 3.6")
+ find_program(CLANGTIDY clang-tidy)
+ if(CLANGTIDY)
+ set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY})
else()
- find_program(CLANGTIDY clang-tidy)
- if(CLANGTIDY)
- set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY})
- else()
- message(SEND_ERROR "Clang-Tidy requested but executable not found")
- endif()
+ message(SEND_ERROR "Clang-Tidy requested but executable not found")
endif()
endif()
set_tests_properties(
"test.${name}"
PROPERTIES
- ENVIRONMENT "CCACHE=$<TARGET_FILE:ccache>;EXIT_IF_SKIPPED=true")
-
- if(${CMAKE_VERSION} VERSION_LESS "3.9")
- # Older CMake versions treat skipped tests as errors. Therefore, resort to
- # parsing output for those cases (exit code is not considered). Skipped
- # tests will appear as "Passed".
- set_tests_properties(
- "test.${name}"
- PROPERTIES
- PASS_REGULAR_EXPRESSION "PASSED|Passed|Skipped"
- FAIL_REGULAR_EXPRESSION "[Ww]arning|[Ff]ail|[Er]rror")
- else()
- set_tests_properties("test.${name}" PROPERTIES SKIP_RETURN_CODE 125)
- endif()
-
+ ENVIRONMENT "CCACHE=$<TARGET_FILE:ccache>;EXIT_IF_SKIPPED=true"
+ SKIP_RETURN_CODE 125)
endfunction()
if(${CMAKE_VERSION} VERSION_LESS "3.15")