Skip to content

Commit

Permalink
fixed #13343 - Bump cmake_minimum_required() to 3.13 (#7213)
Browse files Browse the repository at this point in the history
and do associated cleanups.
    
Fixes #13343
    
Recent CMake versions emit:
```
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.
  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
```
  • Loading branch information
rouault authored Jan 23, 2025
1 parent a8a09a7 commit 54a9ba4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 46 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
cmake_minimum_required(VERSION 3.5)
if(MSVC)
cmake_minimum_required(VERSION 3.13)
endif()
cmake_minimum_required(VERSION 3.13)
project(Cppcheck VERSION 2.16.99 LANGUAGES CXX)

include(cmake/options.cmake)
Expand Down
11 changes: 1 addition & 10 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,7 @@ endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
find_package(Python COMPONENTS Interpreter)
else()
find_package(PythonInterp 3 QUIET)
if(PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python_VERSION ${PYTHON_VERSION_STRING})
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
endif()
endif()
find_package(Python COMPONENTS Interpreter)

if(NOT Python_Interpreter_FOUND)
if(NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
Expand Down
4 changes: 0 additions & 4 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ 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.")
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 readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The minimum required Python version is 3.6.
### CMake
The minimum required version is CMake 3.5.
The minimum required version is CMake 3.13.
Example, compiling Cppcheck with cmake:
Expand Down
50 changes: 23 additions & 27 deletions test/signal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
if (CMAKE_VERSION VERSION_EQUAL "3.13" OR CMAKE_VERSION VERSION_GREATER "3.13")
# target_link_options requires CMake 3.13
add_executable(test-signalhandler
test-signalhandler.cpp
${PROJECT_SOURCE_DIR}/cli/signalhandler.cpp
${PROJECT_SOURCE_DIR}/cli/stacktrace.cpp)
target_include_directories(test-signalhandler PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# names for static functions are omitted from trace
target_compile_options_safe(test-signalhandler -Wno-missing-declarations)
target_compile_options_safe(test-signalhandler -Wno-missing-prototypes)
# required for backtrace() to produce function names
target_link_options(test-signalhandler PRIVATE -rdynamic)
endif()

add_executable(test-signalhandler
test-signalhandler.cpp
${PROJECT_SOURCE_DIR}/cli/signalhandler.cpp
${PROJECT_SOURCE_DIR}/cli/stacktrace.cpp)
target_include_directories(test-signalhandler PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# names for static functions are omitted from trace
target_compile_options_safe(test-signalhandler -Wno-missing-declarations)
target_compile_options_safe(test-signalhandler -Wno-missing-prototypes)
# required for backtrace() to produce function names
target_link_options(test-signalhandler PRIVATE -rdynamic)
endif()

add_executable(test-stacktrace
test-stacktrace.cpp
${PROJECT_SOURCE_DIR}/cli/stacktrace.cpp)
target_include_directories(test-stacktrace PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# names for static functions are omitted from trace
target_compile_options_safe(test-stacktrace -Wno-missing-declarations)
target_compile_options_safe(test-stacktrace -Wno-missing-prototypes)
# required for backtrace() to produce function names
target_link_options(test-stacktrace PRIVATE -rdynamic)
endif()
endif()
add_executable(test-stacktrace
test-stacktrace.cpp
${PROJECT_SOURCE_DIR}/cli/stacktrace.cpp)
target_include_directories(test-stacktrace PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# names for static functions are omitted from trace
target_compile_options_safe(test-stacktrace -Wno-missing-declarations)
target_compile_options_safe(test-stacktrace -Wno-missing-prototypes)
# required for backtrace() to produce function names
target_link_options(test-stacktrace PRIVATE -rdynamic)
endif()

0 comments on commit 54a9ba4

Please sign in to comment.