Enable C99 explicitly with CMake where available

This enables compilation as C99 where supported by the compiler.
A workaround with per-compiler hardcoded flags is used for CMake 3.0,
which does not support the C_STANDARD target property.

Fixes #1560.
Closes #1576.
This commit is contained in:
Guillaume Racicot 2019-09-05 09:47:49 -04:00 коммит произвёл Camilla Löwy
Родитель f71b55f83d
Коммит 8f852e0833
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -100,6 +100,16 @@ set_target_properties(glfw PROPERTIES
POSITION_INDEPENDENT_CODE ON
FOLDER "GLFW3")
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0")
set_target_properties(glfw PROPERTIES C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
target_compile_options(glfw PRIVATE
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>>")
endif()
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"