From 0cb0733e33fa9a5a742d66840c981449c72ea9fd Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Thu, 19 Jan 2023 22:33:32 -0800 Subject: [PATCH] Added c++17 flags to build functions --- CMakeLists.txt | 2 -- cmake/GtsamBuildTypes.cmake | 14 ++++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2de8866b4..5a6757a2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,6 @@ if(NOT DEFINED CMAKE_MACOSX_RPATH) set(CMAKE_MACOSX_RPATH 0) endif() -set(CMAKE_CXX_STANDARD 17) - # Set the version number for the library set (GTSAM_VERSION_MAJOR 4) set (GTSAM_VERSION_MINOR 3) diff --git a/cmake/GtsamBuildTypes.cmake b/cmake/GtsamBuildTypes.cmake index b6107e6d8..0db9538f2 100644 --- a/cmake/GtsamBuildTypes.cmake +++ b/cmake/GtsamBuildTypes.cmake @@ -138,16 +138,22 @@ else() set(GTSAM_COMPILE_OPTIONS_PRIVATE_TIMING -g -O3 CACHE STRING "(User editable) Private compiler flags for Timing configuration.") endif() -# Enable C++11: +# Enable C++17: if (NOT CMAKE_VERSION VERSION_LESS 3.8) - set(GTSAM_COMPILE_FEATURES_PUBLIC "cxx_std_11" CACHE STRING "CMake compile features property for all gtsam targets.") + set(GTSAM_COMPILE_FEATURES_PUBLIC "cxx_std_17" CACHE STRING "CMake compile features property for all gtsam targets.") # See: https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html - # This is to enable -std=c++11 instead of -std=g++11 + # TODO(dellaert): is following line still needed or was that only for c++11? set(CMAKE_CXX_EXTENSIONS OFF) + if (MSVC) + # NOTE(jlblanco): seems to be required in addition to the cxx_std_17 above? + # TODO(dellaert): is this the right syntax below? + list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC /std:c++latest) + endif() else() # Old cmake versions: if (NOT MSVC) - list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC $<$:-std=c++11>) + # TODO(dellaert): I just changed 11 to 17 below, hopefully that works + list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC $<$:-std=c++17>) endif() endif()