From c5e3e7ae3d2ff440733698f70c9d6fa463463e68 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 1 Feb 2024 23:15:03 +0000 Subject: [PATCH 1/2] [CMake] remove more old CMake workarounds --- src/cmake/SetC++Version.cmake | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/cmake/SetC++Version.cmake b/src/cmake/SetC++Version.cmake index f1230e944..d9af21925 100644 --- a/src/cmake/SetC++Version.cmake +++ b/src/cmake/SetC++Version.cmake @@ -1,5 +1,4 @@ # A macro to set the C++ version -# Based on https://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake # Copyright (C) 2017, 2020 University College London # Author Kris Thielemans @@ -21,17 +20,8 @@ function(UseCXX VERSION) endif() endif() - if (CMAKE_VERSION VERSION_LESS "3.1") - message(WARNING "Your CMake version is older than v3.1. Attempting to set C++ version to ${VERSION} with compiler flags but this might fail. Please upgrade your CMake.") - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_EXTENSIONS) - set (CMAKE_CXX_FLAGS "-std=gnu++${VERSION} ${CMAKE_CXX_FLAGS}" PARENT_SCOPE) - else() - set (CMAKE_CXX_FLAGS "-std=c++${VERSION} ${CMAKE_CXX_FLAGS}" PARENT_SCOPE) - endif () - else () - set (CMAKE_CXX_STANDARD ${VERSION} PARENT_SCOPE) - set (CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE) - endif () + set (CMAKE_CXX_STANDARD ${VERSION} PARENT_SCOPE) + set (CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE) message(STATUS "Using C++ version ${VERSION}") endfunction(UseCXX) From 9cc0d1f17bdd38ac4cf7d6d66e657c6c8b8c89b8 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 1 Feb 2024 23:15:56 +0000 Subject: [PATCH 2/2] Set correct C++ version for libraries --- src/cmake/stir_lib_target.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cmake/stir_lib_target.cmake b/src/cmake/stir_lib_target.cmake index 53481e4b0..56884b214 100644 --- a/src/cmake/stir_lib_target.cmake +++ b/src/cmake/stir_lib_target.cmake @@ -18,13 +18,8 @@ target_include_directories(${dir} PUBLIC $ $) -# make sure that if you use STIR, the compiler will be set to at least C++11 -if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.8.0") - target_compile_features(${dir} PUBLIC cxx_std_11) -else() - # Older CMake didn't have cxx_std_11 yet, but using auto will presumably force it anyway - target_compile_features(${dir} PUBLIC cxx_auto_type) -endif() +# make sure that if you use STIR, the compiler will be set to what was set via UseCXX +target_compile_features(${dir} PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) target_include_directories(${dir} PUBLIC ${Boost_INCLUDE_DIR}) SET_PROPERTY(TARGET ${dir} PROPERTY FOLDER "Libs")