Skip to content

Commit

Permalink
Correct append of -std to CXX flags
Browse files Browse the repository at this point in the history
The previous approach, in the presence of existing CXX flags, resulted
in a broken CMAKE_CXX_FLAGS value with a `;` in the middle. The
canonical way of adding a compile option is to use the cmake function
`add_compile_options`, which is available from 2.8.12 onwards.

If you need something compatible with cmake 2.8.11 and prior, you can
use `add_definitions(-std=c++0x)` instead.
  • Loading branch information
mqudsi committed Apr 4, 2018
1 parent 8a4a0a0 commit d2000e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include_directories(${PROJECT_SOURCE_DIR}/src)
set(CMAKE_BUILD_TYPE Release)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|Intel")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -Wall")
add_compile_options(-std=c++0x)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Versions of MSVC that support C++11 at all support it by default, so hope
# for the best...
Expand Down

0 comments on commit d2000e5

Please sign in to comment.