summaryrefslogtreecommitdiff
path: root/cmake/TestCInline.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/TestCInline.cmake')
-rw-r--r--cmake/TestCInline.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmake/TestCInline.cmake b/cmake/TestCInline.cmake
new file mode 100644
index 0000000..4fdd4c5
--- /dev/null
+++ b/cmake/TestCInline.cmake
@@ -0,0 +1,28 @@
+#Inspired from http://www.cmake.org/Wiki/CMakeTestInline
+
+IF(NOT DEFINED C_INLINE_DETECTED)
+
+ SET(INLINE_TEST_SRC "/* Inspired by autoconf's c.m4 */
+static inline int static_foo() {return 0\;}
+int main(int argc, char *argv[]){return 0\;}
+")
+
+ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CMakeTestCInline.c ${INLINE_TEST_SRC})
+
+ FOREACH(KEYWORD "inline" "__inline__" "__inline")
+ IF(NOT DEFINED C_INLINE)
+ TRY_COMPILE(C_HAS_${KEYWORD}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeTestCInline.c
+ COMPILE_DEFINITIONS "-Dinline=${KEYWORD}"
+ )
+ IF(C_HAS_${KEYWORD})
+ SET(C_INLINE ${KEYWORD})
+ ENDIF(C_HAS_${KEYWORD})
+ ENDIF(NOT DEFINED C_INLINE)
+ ENDFOREACH(KEYWORD)
+
+ SET(C_INLINE_DETECTED True CACHE BOOL INTERNAL)
+
+ENDIF(NOT DEFINED C_INLINE_DETECTED)
+