Skip to content

Commit

Permalink
add c++11 check for msvc (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kejxu committed Feb 15, 2019
1 parent 00f9b38 commit 8ed6f42
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ include_directories("${CATKIN_DEVEL_PREFIX}/include")
configure_file(urdfdom_compatibility.h.in "${generated_compat_header}" @ONLY)

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
add_compile_options(-std=c++11)
unset(COMPILER_SUPPORTS_CXX11 CACHE)
if(MSVC)
# https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
# MSVC will fail the following check since it does not have the c++11 switch
# however, c++11 is always enabled (the newer /std:c++14 is enabled by default)
check_cxx_compiler_flag(/std:c++11 COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
add_compile_options(/std:c++11)
endif()
else()
check_cxx_compiler_flag(-std=c++11 COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
add_compile_options(-std=c++11)
endif()
endif()

catkin_package(
Expand Down

0 comments on commit 8ed6f42

Please sign in to comment.