Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cxx standard detection under windows with msvc #1308

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
53 changes: 37 additions & 16 deletions cmake/VISPDetectCXXStandard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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")
Expand Down
Loading