aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-10-03 05:45:12 -0700
committerChris Robinson <[email protected]>2013-10-03 05:45:12 -0700
commit01a5946a2e371485e4e0774e7dd543ad3a1f0675 (patch)
tree04ef80e1b13c9bbe76c97c1cee108d8a9a1f7ee6 /CMakeLists.txt
parent2e605590a264b96f08c36f09b1d969cc9808d5ac (diff)
Compile using -std=c99 when available
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 8 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f39c910f..4b9d3ba4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -100,10 +100,17 @@ CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
+CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
+IF(HAVE_STD_C99)
+ SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
+ENDIF()
+
+# TODO: Once we truly require C99, these restrict and inline checks should go
+# away. Currently they're needed to maintain MSVC compatibility.
CHECK_C_SOURCE_COMPILES("int *restrict foo;
int main() {return 0;}" HAVE_RESTRICT)
IF(NOT HAVE_RESTRICT)
- # Slightly convoluted way to do this, because MSVC may barf is restrict is
+ # Slightly convoluted way to do this, because MSVC may barf if restrict is
# defined to __restrict.
CHECK_C_SOURCE_COMPILES("#define restrict __restrict
#include <stdlib.h>