diff --git a/ChangeLog.txt b/ChangeLog.txt index d5f9e64b17..d8a85ed998 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -39,6 +39,7 @@ ViSP 3.x.x (Version in development) . [#1274] Build issue no member named clamp in namespace std . [#1279] Issue in vpPoseVector json serialization . [#1296] Unable to parse camera parameters with vpXmlParserCamera::parse() when camera name is empty + . [#1307] Cannot set cxx standard when configuring for Visual Studio ---------------------------------------------- ViSP 3.6.0 (released September 22, 2023) - Contributors: diff --git a/cmake/VISPDetectCXXStandard.cmake b/cmake/VISPDetectCXXStandard.cmake index 6169763899..3057f0dc6e 100644 --- a/cmake/VISPDetectCXXStandard.cmake +++ b/cmake/VISPDetectCXXStandard.cmake @@ -48,39 +48,60 @@ else() # Setting CMAKE_CXX_STANDARD doesn't affect check_cxx_source_compiles() used to detect isnan() in FindIsNaN.cmake # or erfc() in FindErfc.cmake. # That's why we have the following lines that are used to set cxx flags corresponding to the c++ standard - vp_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") - if(HAVE_STD_CXX11_FLAG) - set(CXX11_CXX_FLAGS "-std=c++11" CACHE STRING "C++ compiler flags for C++11 support") + vp_check_compiler_flag(CXX "" HAVE_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") + if(HAVE_CXX11_FLAG) set(CXX11_STANDARD_FOUND ON CACHE STRING "cxx11 standard") mark_as_advanced(CXX11_STANDARD_FOUND) - mark_as_advanced(CXX11_CXX_FLAGS) - mark_as_advanced(HAVE_STD_CXX11_FLAG) + mark_as_advanced(HAVE_CXX11_FLAG) + else() + vp_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx11.cpp") + if(HAVE_STD_CXX11_FLAG) + set(CXX11_CXX_FLAGS "-std=c++11" CACHE STRING "C++ compiler flags for C++11 support") + set(CXX11_STANDARD_FOUND ON CACHE STRING "cxx11 standard") + mark_as_advanced(CXX11_STANDARD_FOUND) + mark_as_advanced(CXX11_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX11_FLAG) + endif() endif() endif() endif() if(CMAKE_CXX14_COMPILE_FEATURES) # Additionnal check in case of c++14 is incomplete and also needed to set CXX14_CXX_FLAGS - vp_check_compiler_flag(CXX "-std=c++14" HAVE_STD_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") - if(HAVE_STD_CXX14_FLAG) - set(CXX14_CXX_FLAGS "-std=c++14" CACHE STRING "C++ compiler flags for C++14 support") + vp_check_compiler_flag(CXX "" HAVE_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") + if(HAVE_CXX14_FLAG) set(CXX14_STANDARD_FOUND ON CACHE STRING "cxx14 standard") mark_as_advanced(CXX14_STANDARD_FOUND) - mark_as_advanced(CXX14_CXX_FLAGS) - mark_as_advanced(HAVE_STD_CXX14_FLAG) + mark_as_advanced(HAVE_CXX14_FLAG) + else() + vp_check_compiler_flag(CXX "-std=c++14" HAVE_STD_CXX14_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx14.cpp") + if(HAVE_STD_CXX14_FLAG) + set(CXX14_CXX_FLAGS "-std=c++14" CACHE STRING "C++ compiler flags for C++14 support") + set(CXX14_STANDARD_FOUND ON CACHE STRING "cxx14 standard") + mark_as_advanced(CXX14_STANDARD_FOUND) + mark_as_advanced(CXX14_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX14_FLAG) + endif() endif() endif() if(CMAKE_CXX17_COMPILE_FEATURES) # c++17 seems available, but on Fedora 25 and g++ 6.3.1 it seems incomplete where # optional header is not found as well as std::clamp() - vp_check_compiler_flag(CXX "-std=c++17" HAVE_STD_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") - if(HAVE_STD_CXX17_FLAG) - set(CXX17_CXX_FLAGS "-std=c++17" CACHE STRING "C++ compiler flags for C++17 support") + vp_check_compiler_flag(CXX "" HAVE_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") + if(HAVE_CXX17_FLAG) set(CXX17_STANDARD_FOUND ON CACHE STRING "cxx17 standard") mark_as_advanced(CXX17_STANDARD_FOUND) - mark_as_advanced(CXX17_CXX_FLAGS) - mark_as_advanced(HAVE_STD_CXX17_FLAG) + mark_as_advanced(HAVE_CXX17_FLAG) + else() + vp_check_compiler_flag(CXX "-std=c++17" HAVE_STD_CXX17_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cxx17.cpp") + if(HAVE_STD_CXX17_FLAG) + set(CXX17_CXX_FLAGS "-std=c++17" CACHE STRING "C++ compiler flags for C++17 support") + set(CXX17_STANDARD_FOUND ON CACHE STRING "cxx17 standard") + mark_as_advanced(CXX17_STANDARD_FOUND) + mark_as_advanced(CXX17_CXX_FLAGS) + mark_as_advanced(HAVE_STD_CXX17_FLAG) + endif() endif() endif() @@ -102,7 +123,7 @@ else() if(AVAILABLE_CXX_STANDARD) if(CXX11_STANDARD_FOUND) - set_property(CACHE USE_CXX_STANDARD APPEND_STRING PROPERTY STRINGS ";11") + set_property(CACHE USE_CXX_STANDARD APPEND_STRING PROPERTY STRINGS "11") endif() if(CXX14_STANDARD_FOUND) set_property(CACHE USE_CXX_STANDARD APPEND_STRING PROPERTY STRINGS ";14")