From a4881f40d2862f193cc38f9759564370004215c4 Mon Sep 17 00:00:00 2001 From: Michael Steinert Date: Tue, 15 May 2012 18:03:46 -0600 Subject: Move TestCInline.cmake into cmake directory Signed-off-by: Michael Steinert --- cmake/TestCInline.cmake | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmake/TestCInline.cmake (limited to 'cmake/TestCInline.cmake') 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) + -- cgit v1.2.1