CMake as a set of handy properties that correspond to setting certain feature test macros in the underlying compiler. For example, with gcc:
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
will result in the following flags being passed:
-std=c11 -Wpedantic
which will also set the feature test macros
_ISOC11_SOURCE
This works quite well as I can rely on CMake to deal with the differences between compilers. I was looking through the list of feature test macros that CMakes supports, however, and I couldn't locate any related to the _POSIX_C_SOURCE feature test. Is there any better way to do this other than add_definitions(-D_POSIX_C_SOURCE=200809L)?