From: Martin Quinson Date: Sat, 12 Jan 2019 16:50:12 +0000 (+0100) Subject: Correctly search C++14 on older cmake X-Git-Tag: v3_22~580 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/22d44171727ee072c6b108f7e89b06b8c6f48c70?hp=8027c7e2096e3eb887cc011b1937d10ae568310a Correctly search C++14 on older cmake We need to first ask cmake whether it knows about a given feature before testing whether the compiler has that feature. In particular, only cmake 3.8 and higher knows about the cxx_std_14 feature. Since we use the IN_LIST operator to test whether cmake knows a given feature, we need to bump our CMake minimal version to 3.5. That's a huge bump from the previous 2.8 requirement, but that version is provided on Ubuntu Xenial (16.04), our oldest build slave. Note that cxx_std_14 as a CMAKE_CXX_KNOWN_FEATURES was introduced by cmake 3.8 only, while versions between 3.5 and 3.8 only had individual features composing C++14, not the global 'cxx_std_14'. But that's OK. People should use recent tools to get better/all features. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d930151482..c9786cf333 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.8) +cmake_minimum_required(VERSION 3.5) 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) @@ -768,20 +768,32 @@ if(enable_java) include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Java.cmake) endif() -# Python binding, generated with pybind11 -find_package(pybind11 2.2.0) -if(NOT PYTHONLIBS_FOUND) +# Python binding (with pybind11) +################ + +# Our usage of pybind11::overload_cast mandates C++14 +get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) +if ("cxx_std_14" IN_LIST known_features) + find_package(pybind11 2.2.0) + if(NOT PYTHONLIBS_FOUND) + set(pybind11_FOUND OFF) + endif() +else() + message(STATUS "No support for C++14 detected, don't even search for pybind11.") set(pybind11_FOUND OFF) endif() +unset(known_features) + option(enable_python "Whether the Python bindings are activated." ${pybind11_FOUND}) # ON by default if dependencies are met if("${CMAKE_SYSTEM}" MATCHES "FreeBSD" AND enable_model-checking AND enable_python) - message(WARNING "FreeBSD + Model-Checking + Python = too much for now. Disabling python") + message(WARNING "FreeBSD + Model-Checking + Python = too much for now. Disabling python.") set(enable_python FALSE) endif() if(enable_python) if(pybind11_FOUND) + message(STATUS "Found pybind11, with C++14.") pybind11_add_module(python-bindings src/bindings/python/simgrid_python.cpp) target_compile_features(python-bindings PRIVATE cxx_std_14) target_link_libraries(python-bindings PUBLIC simgrid) diff --git a/ChangeLog b/ChangeLog index 670024686f..1dc467f917 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Core: - Replace our own code to display a backtrace (that was forking addr2line) with the Boost.Stacktrace library. You won't see your backtraces without this optional dependency. + - Bump cmake dependency to 3.5 (provided by Ubuntu 16.04). MSG: - Drop MSG_process_create_from_stdfunc() from the API.