Merge branch 'release-4-5-patches'
[gromacs/adressmacs.git] / cmake / gmxTestInline.cmake
blobf1108b6e10f3fdb7747b1fb278108f1a9d3296bd
1 # - Define macro to check inline keyword
3 #  GMX_TEST_INLINE(VARIABLE)
5 #  VARIABLE will be set to the keyword
7 #  Remember to have a cmakedefine for it too...
9 MACRO(GMX_TEST_INLINE VARIABLE)
10     IF(NOT DEFINED TEST_${VARIABLE})
12         MESSAGE(STATUS "Checking for inline keyword")
14         FOREACH(KEYWORD "inline" "__inline__" "__inline")
15             IF(NOT TEST_${VARIABLE})
16                 TRY_COMPILE(TEST_${VARIABLE} "${CMAKE_BINARY_DIR}"    
17                             "${CMAKE_SOURCE_DIR}/cmake/TestInline.c"
18                             COMPILE_DEFINITIONS "-DTESTINLINEDEF=${KEYWORD}" )
19                 SET(CHK_INLINE_KEYWORD ${KEYWORD})
20             ENDIF(NOT TEST_${VARIABLE})
21         ENDFOREACH(KEYWORD)
22              
23         IF(TEST_${VARIABLE})
24             SET(${VARIABLE} ${KEYWORD})
25             MESSAGE(STATUS "Checking for inline keyword - ${CHK_INLINE_KEYWORD}")
26         ELSE(TEST_${VARIABLE})
27             SET(${VARIABLE} " ")
28             MESSAGE(STATUS "Checking for inline keyword - not found")
29         ENDIF(TEST_${VARIABLE})
31     ENDIF(NOT DEFINED TEST_${VARIABLE})        
32 ENDMACRO(GMX_TEST_INLINE VARIABLE)