diff options
author | Chris Robinson <[email protected]> | 2018-10-27 18:58:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-10-29 10:10:37 -0700 |
commit | fd1361c1982e28fe4be287cb41ae24c3fc926ae8 (patch) | |
tree | bc38cbff54709927bf4586a9b577e02c04b42a7b /CMakeLists.txt | |
parent | 5148a73a7bc8cc0cad1e157930c936c75e40da2e (diff) |
Add a RESTRICT macro to help with C++ compatibility
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c05bcb10..6247af93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,17 +155,17 @@ ENDIF() SET(CPP_DEFS ${CPP_DEFS} _LARGEFILE_SOURCE _LARGE_FILES) SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES") +# C99 has restrict, but C++ does not, so we can only utilize __restrict. +SET(RESTRICT_DECL ) +CHECK_C_SOURCE_COMPILES("int *__restrict foo; + int main() {return 0;}" HAVE___RESTRICT) +IF(HAVE___RESTRICT) + SET(RESTRICT_DECL "__restrict") +ENDIF() + # MSVC may need workarounds for C99 restrict and inline IF(MSVC) - # TODO: Once we truly require C99, these restrict and inline checks should go - # away. - CHECK_C_SOURCE_COMPILES("int *restrict foo; - int main() {return 0;}" HAVE_RESTRICT) - IF(NOT HAVE_RESTRICT) - SET(CPP_DEFS ${CPP_DEFS} "restrict=") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=") - ENDIF() - + # TODO: Once we truly require C99, this inline check should go away. CHECK_C_SOURCE_COMPILES("inline void foo(void) { } int main() {return 0;}" HAVE_INLINE) IF(NOT HAVE_INLINE) |