]> prime8.dev >> repos - ttyd.git/commitdiff
cmake: fix c99 mode for old versions of cmake
authorShuanglei Tao <tsl0922@gmail.com>
Mon, 2 Jan 2017 16:14:57 +0000 (00:14 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Mon, 2 Jan 2017 16:15:13 +0000 (00:15 +0800)
CMakeLists.txt

index 7f1533735fb222d775c25565400e5beb70fbb836..71714fec2dfce5349a71e46b0c904fac5f8b7cd7 100644 (file)
@@ -1,14 +1,17 @@
 cmake_minimum_required(VERSION 2.8)
 
-# enable C99 mode
+project(ttyd)
+
 if(CMAKE_VERSION VERSION_LESS "3.1")
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+    if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
+    else()
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+    endif()
 else()
-    set (CMAKE_C_STANDARD 99)
+    set(CMAKE_C_STANDARD 99)
 endif()
 
-project(ttyd)
-
 set(LIBWEBSOCKETS_MIN_VERSION 1.7.0)
 set(SOURCE_FILES src/server.c src/http.c src/protocol.c src/utils.c)