From 3f0390b8273af6555eb31919c5ea4f7c32537374 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Thu, 5 Sep 2019 09:47:49 -0400 Subject: [PATCH] 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 8f852e0833be7fa762d70c804c7856b537da9376) --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06867308..0af6dd05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 + "$<$:-std=c99>" + "$<$:-std=c99>>" + "$<$:-std=c99>>") +endif() + target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw PUBLIC "$"