Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
cmake_minimum_required(VERSION 3.5)
project(Cppcheck)
if (MSVC)
cmake_minimum_required(VERSION 3.13)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subsequent calls to raise the required version are allowed

endif()
cmake_policy(SET CMP0048 NEW) # allow VERSION in project()
project(Cppcheck VERSION 2.13.99 LANGUAGES CXX)

include(cmake/cxx11.cmake)
use_cxx11()
set (CMAKE_CXX_STANDARD_REQUIRED ON)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from cxx11.cmake as it is generic and available now.


set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(GNUInstallDirs)

include(cmake/ccache.cmake)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary. Was a work around for CMake 2.8.

include(cmake/compilerCheck.cmake)
include(cmake/versions.cmake)
include(cmake/options.cmake)
Expand Down
7 changes: 0 additions & 7 deletions cmake/ccache.cmake

This file was deleted.

2 changes: 2 additions & 0 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
if (MSVC)
# add_compile_definitions() requires CMake 3.12

# Visual Studio only sets _DEBUG
add_compile_definitions($<$<CONFIG:Debug>:DEBUG>)

Expand Down
4 changes: 3 additions & 1 deletion cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

if (USE_LIBCXX)
add_compile_options(-stdlib=libc++)
add_link_options(-lc++)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
endif()

# TODO: fix and enable these warnings - or move to suppression list below
Expand Down Expand Up @@ -133,6 +133,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

if (MSVC)
# add_link_options() requires CMake 3.13

# General
add_compile_options(/W4) # Warning Level
add_compile_options(/Zi) # Debug Information Format - Program Database
Expand Down
23 changes: 6 additions & 17 deletions cmake/cxx11.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif ()
# some GitHub Action Windows runners randomly fail with a complaint that Qt6 requires a C++17 compiler
if (MSVC AND USE_QT6)
# CMAKE_CXX_STANDARD 17 was added in CMake 3.8
set (CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use")
else ()
# some GitHub Action windows runners randomly fail with a complaint that Qt6 requires a C++17 compiler
if (MSVC)
set (CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use")
else ()
set (CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
endif()
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif ()
endif ()
set (CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
endif()
endmacro(use_cxx11)
4 changes: 4 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ else()
set(CMAKE_DISABLE_PRECOMPILE_HEADERS On CACHE BOOL "Disable precompiled headers")
endif()

if (BUILD_TESTS AND REGISTER_TESTS AND CMAKE_VERSION VERSION_LESS "3.9")
message(FATAL_ERROR "Registering tests with CTest requires at least CMake 3.9. Use REGISTER_TESTS=OFF to disable this.")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would have bailed out in the test code later on before. I moved it up so there is not a stray cmake_minimum_required() call somewhere in the code.

endif()

set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "Output directory for headers")
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_INSTALL_PREFIX}/lib CACHE PATH "Output directory for libraries")

Expand Down
2 changes: 1 addition & 1 deletion cmake/printInfo.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${VERSION} -----------------")
message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${PROJECT_VERSION} -----------------")
message( STATUS )
message( STATUS "CMake Version = ${CMAKE_VERSION}")
message( STATUS "CMake Generator = ${CMAKE_GENERATOR}")
Expand Down
7 changes: 1 addition & 6 deletions cmake/versions.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Version for libraries CPP
# Version string must have 3 "parts". https://sourceforge.net/p/cppcheck/discussion/development/thread/e57efb2b62/
SET(VERSION "2.13.99")
STRING(REGEX MATCHALL "[0-9]+" VERSION_PARTS "${VERSION}")
LIST(GET VERSION_PARTS 0 VERSION_MAJOR)
LIST(GET VERSION_PARTS 1 VERSION_MINOR)
LIST(GET VERSION_PARTS 2 VERSION_PATCH)
SET(SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
SET(SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

# Postfix of so's:
SET(DLLVERSION "")
Expand Down
1 change: 1 addition & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Other:
- Added CMake option 'EXTERNALS_AS_SYSTEM' to treat external includes as 'SYSTEM' ones.
- The minimum required compiler versions have been bumped to GCC 5.1 / Clang 3.5 / Visual Studio 2015
- The minimum required CMake version has been bumped to 3.5
- Using Visual Studio with CMake now checks if the CMake version is at least 3.13. This was always required but was not checked explicitly.
7 changes: 1 addition & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ if (BUILD_TESTS)
endif()

if (REGISTER_TESTS)
# CMP0057 requires 3.3 - if (IN_LIST)
# CMP0064 requires 3.4 - if (TEST)
# CMAKE_MATCH_<n> usage for if (MATCHES) requires 3.9
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0064 NEW)
cmake_policy(SET CMP0057 NEW)
# CMAKE_MATCH_<n> usage for if (MATCHES) requires CMake 3.9

find_package(Threads REQUIRED)
include(ProcessorCount)
Expand Down