Wanted version for C and C++ can be specified globally using respectively variables CMAKE_C_STANDARD
(accepted values are 98, 99 and 11) and CMAKE_CXX_STANDARD
(accepted values are 98, 11 and 14):
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
These will add the needed compile options on targets (e.g. -std=c++11
for gcc).
The version can be made a requirement by setting to ON
the variables CMAKE_C_STANDARD_REQUIRED
and CMAKE_CXX_STANDARD_REQUIRED
respectively.
The variables must be set before target creation. The version can also be specified per-target:
set_target_properties(foo PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)