From 8033578c7938cc79ec840fc74c8eab82efbd9454 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 2 Oct 2020 21:38:33 +0200 Subject: [PATCH] C++14 support is now required. --- CMakeLists.txt | 61 +++++++++++++++++------------------------------ ChangeLog | 3 ++- FindSimGrid.cmake | 26 ++++++++++++-------- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e97ab04a00..1af66cbd8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,15 +51,15 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") if (CMAKE_COMPILER_IS_GNUCC) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") message(FATAL_ERROR - "SimGrid needs at least g++ version 4.7 to compile but you have ${CMAKE_CXX_COMPILER_VERSION}." - "You need a sufficient support of c++11 to compile SimGrid.") + "SimGrid needs at least g++ version 5.0 to compile but you have ${CMAKE_CXX_COMPILER_VERSION}." + "You need a sufficient support of c++14 to compile SimGrid.") endif() endif() -## We need a decent support of the C++11 and C11 standards -set(CMAKE_CXX_STANDARD 11) +## We need a decent support of the C++14 and C11 standards +set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 11) @@ -427,8 +427,6 @@ if (enable_model-checking AND enable_ns3) message(FATAL_ERROR "Cannot activate both model-checking and ns-3 bindings: ns-3 pulls too much dependencies for the MC to work") endif() -get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) - if(enable_smpi) SET(HAVE_SMPI 1) if(WIN32) @@ -793,47 +791,32 @@ if(enable_java) include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Java.cmake) endif() -if (enable_model-checking AND (NOT ("cxx_std_14" IN_LIST known_features))) - message(WARNING "C++14 not found. The model-checker will use a slow hash function. You should upgrade your compiler") -else() - set_property(TARGET simgrid PROPERTY CXX_STANDARD 14) -endif() - # Python binding (with pybind11) ################ -# Our usage of pybind11::overload_cast mandates C++14 if((NOT DEFINED enable_python) OR enable_python) - if("cxx_std_14" IN_LIST known_features) - - if(EXISTS ${CMAKE_HOME_DIRECTORY}/pybind11) # Try to use a local copy of pybind11, if any - message(STATUS "Use the internal copy of pybind11 (using C++14).") - add_subdirectory(${CMAKE_HOME_DIRECTORY}/pybind11) - set(pybind11_FOUND ON) - - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/pybind11/tools/) - set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4) - find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED) - - else() - find_package(pybind11 CONFIG) - message(STATUS "Pybind11 version: ${pybind11_VERSION}") - if (pybind11_VERSION VERSION_LESS 2.4) - message(STATUS "SimGrid needs at least v2.4 of pybind11. Disabling the Python bindings.") - set(pybind11_FOUND OFF) - endif() - endif() + if(EXISTS ${CMAKE_HOME_DIRECTORY}/pybind11) # Try to use a local copy of pybind11, if any + message(STATUS "Use the internal copy of pybind11.") + add_subdirectory(${CMAKE_HOME_DIRECTORY}/pybind11) + set(pybind11_FOUND ON) - if(NOT PYTHONLIBS_FOUND) - message(STATUS "Python libs not found. Turn pybind11 off.") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/pybind11/tools/) + set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4) + find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED) + else() + find_package(pybind11 CONFIG) + message(STATUS "Pybind11 version: ${pybind11_VERSION}") + if (pybind11_VERSION VERSION_LESS 2.4) + message(STATUS "SimGrid needs at least v2.4 of pybind11. Disabling the Python bindings.") set(pybind11_FOUND OFF) endif() + endif() + + if(NOT PYTHONLIBS_FOUND) + message(STATUS "Python libs not found. Turn pybind11 off.") - else() - message(STATUS "No support for C++14 detected, don't even search for pybind11.") set(pybind11_FOUND OFF) endif() - unset(known_features) endif() option(enable_python "Whether the Python bindings are activated." ${pybind11_FOUND}) # ON by default if dependencies are met @@ -845,7 +828,7 @@ endif() if(enable_python) if(pybind11_FOUND) - message(STATUS "Found pybind11, with C++14.") + message(STATUS "Found pybind11.") if(NOT enable_lto) set(pybind11_options NO_EXTRAS) endif() diff --git a/ChangeLog b/ChangeLog index ce874a1eda..3ccecb93ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,7 +25,7 @@ S4U: - the on_exit() of each actor is also executed when the simulation deadlocks. SMPI: - - Update proxy apps coverage of new ECP apps: 60+ apps now tested nightly on + - Update proxy apps coverage of new ECP apps: 60+ apps now tested nightly on https://framagit.org/simgrid/SMPI-proxy-apps - MPI/IO: supports names starting with "./" - Fortran: many MPI/IO bindings, support for MPI_UB/LB, C MPI_INT/FLOAT/DOUBLE @@ -39,6 +39,7 @@ C binding: (int value was previously ignored) General: + - Require a compiler with C++14 support. - LTO is now enabled for Intel/clang compilers. - LTO behavior on GCC can be parameterized using LTO_EXTRA_FLAG in cmake. Setting it to "auto" will use all available cores, while setting it to n will diff --git a/FindSimGrid.cmake b/FindSimGrid.cmake index 2902b526dc..1b1817689e 100644 --- a/FindSimGrid.cmake +++ b/FindSimGrid.cmake @@ -45,7 +45,7 @@ # (code to use with SimGrid v3.19+) # #endif # -# Since SimGrid header files require C++11, so we set CMAKE_CXX_STANDARD to 11. +# Since SimGrid header files require C++14, so we set CMAKE_CXX_STANDARD to 14. # Change this variable in your own file if you need a later standard. # @@ -58,7 +58,7 @@ cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_path(SimGrid_INCLUDE_DIR @@ -117,22 +117,28 @@ if (SimGrid_FOUND AND NOT CMAKE_VERSION VERSION_LESS 2.8.12) INTERFACE_COMPILE_FEATURES cxx_alias_templates IMPORTED_LOCATION ${SimGrid_LIBRARY} ) - # We need C++11, so check for it just in case the user removed it since compiling SimGrid + # We need C++14, so check for it just in case the user removed it since compiling SimGrid if (NOT CMAKE_VERSION VERSION_LESS 3.8) # 3.8+ allows us to simply require C++11 (or higher) - set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11) + set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_14) elseif (NOT CMAKE_VERSION VERSION_LESS 3.1) # 3.1+ is similar but for certain features. We pick just one - set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_alias_templates) + set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_attribute_deprecated) else () - # Old CMake can't do much. Just check the CXX_FLAGS and inform the user when a C++11 feature does not work + # Old CMake can't do much. Just check the CXX_FLAGS and inform the user when a C++14 feature does not work include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS}") - check_cxx_source_compiles("using Foo = int; int main(){}" _SIMGRID_CXX11_ENABLED) - if (NOT _SIMGRID_CXX11_ENABLED) - message(WARNING "C++11 is required to use SimGrid. Enable it with e.g. -std=c++11") + check_cxx_source_compiles(" +#if __cplusplus < 201402L +#error +#else +int main(){} +#endif +" _SIMGRID_CXX14_ENABLED) + if (NOT _SIMGRID_CXX14_ENABLED) + message(WARNING "C++14 is required to use SimGrid. Enable it with e.g. -std=c++14") endif () - unset(_SIMGRID_CXX11_ENABLED CACHE) + unset(_SIMGRID_CXX14_ENABLED CACHE) endif () endif () -- 2.20.1