From a4a9fe4953506ffd0a5b4c4363fcb928ab18d23f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 3 Mar 2023 23:57:15 +0100 Subject: [PATCH] Bump cmake to at least 3.12 - It's difficult to search for Python Development component before that version - This version is available in Debian buster (oldstable) --- CMakeLists.txt | 26 ++++++-------------------- examples/sthread/CMakeLists.txt | 2 +- tools/cmake/Flags.cmake | 16 ++++------------ 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d9bb8b7d7..f702831160 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,12 +21,8 @@ set(SIMGRID_VERSION_STRING "SimGrid version ${release_version}") set(libsimgrid_version "${release_version}") # Basic checks on cmake -cmake_minimum_required(VERSION 3.5) -#for lto, to avoid warning (should be removed when switching to requiring cmake >= 3.9) -if(NOT CMAKE_VERSION VERSION_LESS "3.9") - cmake_policy(SET CMP0069 NEW) -endif() -# once we move >= 3.13, we should use target_link_option in examples/sthread +cmake_minimum_required(VERSION 3.12) +# once we move CMake to >= 3.13, we should use target_link_option in examples/sthread message(STATUS "Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/tools/cmake/Modules) @@ -132,21 +128,11 @@ if(NOT PERL_FOUND) endif() # tesh.py needs python 3 (or the module python-subprocess32 on python2.8+) -if(CMAKE_VERSION VERSION_LESS "3.12") - set(PythonInterp_FIND_VERSION 3) - set(PythonInterp_FIND_VERSION_COUNT 1) - set(PythonInterp_FIND_VERSION_MAJOR 3) - include(FindPythonInterp) - if(NOT PYTHONINTERP_FOUND) - message(FATAL_ERROR "Please install Python (version 3 or higher) to compile SimGrid.") - endif() -else() - find_package(Python3 COMPONENTS Interpreter) - if(NOT Python3_Interpreter_FOUND) - message(FATAL_ERROR "Please install Python (version 3 or higher) to compile SimGrid.") - endif() - set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +find_package(Python3 COMPONENTS Interpreter) +if(NOT Python3_Interpreter_FOUND) + message(FATAL_ERROR "Please install Python (version 3 or higher) to compile SimGrid.") endif() +set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) diff --git a/examples/sthread/CMakeLists.txt b/examples/sthread/CMakeLists.txt index d53f419c2c..2f6f99f85c 100644 --- a/examples/sthread/CMakeLists.txt +++ b/examples/sthread/CMakeLists.txt @@ -40,7 +40,7 @@ foreach(x add_executable (pthread-${x} EXCLUDE_FROM_ALL pthread-${x}.c) set_target_properties(pthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(pthread-${x} PRIVATE Threads::Threads) - target_link_libraries(pthread-${x} PUBLIC "-Wl,-znorelro -Wl,-znoseparate-code") # TODO: convert to target_link_option once cmake is >3.13 + target_link_libraries(pthread-${x} PUBLIC "-Wl,-znorelro -Wl,-znoseparate-code") # TODO: convert to target_link_option once CMAKE_VERSION is >3.13 add_dependencies(tests-mc pthread-${x}) ADD_TESH_FACTORIES(pthread-mc-${x} "^thread" --setenv libdir=${CMAKE_BINARY_DIR}/lib --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/pthread-mc-${x}.tesh) diff --git a/tools/cmake/Flags.cmake b/tools/cmake/Flags.cmake index f90b2b40e8..60aeeca6ad 100644 --- a/tools/cmake/Flags.cmake +++ b/tools/cmake/Flags.cmake @@ -122,18 +122,10 @@ if(enable_lto) # User wants LTO. Try if we can do that set(enable_lto OFF) if(enable_compile_optimizations AND (NOT enable_model-checking)) - if(CMAKE_VERSION VERSION_LESS "3.9") - if ( CMAKE_COMPILER_IS_GNUCC - AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.5") - AND (LINKER_VERSION VERSION_GREATER "2.22")) - set(enable_lto ON) - endif() - else() - include(CheckIPOSupported) - check_ipo_supported(RESULT ipo LANGUAGES C CXX) - if(ipo) - set(enable_lto ON) - endif() + include(CheckIPOSupported) + check_ipo_supported(RESULT ipo LANGUAGES C CXX) + if(ipo) + set(enable_lto ON) endif() endif() -- 2.20.1