I would like to add -std=c++11 to my
add_compile_options(\"-std=c++11\")
However, this also adds them to compilation of C
You can use LINKER_LANGUAGE target property to add flag only to C++ targets*:
add_compile_options(
"$<$,CXX>:-std=c++11>"
)
*Note that this will not work for targets with mixed C/C++ sources
CMAKE_CXX_FLAGS should work fine too:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
Probably you need to add them to cache if it set before project command (e.g. in toolchain):
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" CACHE STRING "" FORCE)