Skip to content

Commit 8ed6f42

Browse files
committed
add c++11 check for msvc (#5)
1 parent 00f9b38 commit 8ed6f42

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

urdf/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,20 @@ include_directories("${CATKIN_DEVEL_PREFIX}/include")
2323
configure_file(urdfdom_compatibility.h.in "${generated_compat_header}" @ONLY)
2424

2525
include(CheckCXXCompilerFlag)
26-
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
27-
if(COMPILER_SUPPORTS_CXX11)
28-
add_compile_options(-std=c++11)
26+
unset(COMPILER_SUPPORTS_CXX11 CACHE)
27+
if(MSVC)
28+
# https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
29+
# MSVC will fail the following check since it does not have the c++11 switch
30+
# however, c++11 is always enabled (the newer /std:c++14 is enabled by default)
31+
check_cxx_compiler_flag(/std:c++11 COMPILER_SUPPORTS_CXX11)
32+
if(COMPILER_SUPPORTS_CXX11)
33+
add_compile_options(/std:c++11)
34+
endif()
35+
else()
36+
check_cxx_compiler_flag(-std=c++11 COMPILER_SUPPORTS_CXX11)
37+
if(COMPILER_SUPPORTS_CXX11)
38+
add_compile_options(-std=c++11)
39+
endif()
2940
endif()
3041

3142
catkin_package(

0 commit comments

Comments
 (0)