1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

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.

(cherry picked from commit 8f852e0833)
This commit is contained in:
Guillaume Racicot 2019-09-05 09:47:49 -04:00 committed by Camilla Löwy
parent 4a62820646
commit 3f0390b827

View File

@ -100,6 +100,16 @@ set_target_properties(glfw PROPERTIES
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
FOLDER "GLFW3") 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_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_include_directories(glfw PUBLIC target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"