1 # This handy test is from Jack Kelly on the cmake email list.
2 # Here is a minimal working example. It tests the inline keyword,
3 # then __inline__ and then __inline. When it finds one that works,
4 # it will ADD_DEFINITIONS(-Dinline=${KEYWORD}) and if none work, it
5 # will ADD_DEFINITIONS(-Dinline=).
7 # Inspired from /usr/share/autoconf/autoconf/c.m4
8 include (CheckCSourceCompiles)
9 FOREACH(KEYWORD "inline" "__inline__" "__inline")
10 IF(NOT DEFINED C_INLINE)
11 check_c_source_compiles(
12 "typedef int foo_t; static inline foo_t static_foo(){return 0;}
13 foo_t foo(){return 0;} int main(int argc, char *argv[]){return 0;}"
17 ADD_DEFINITIONS("-Dinline=${KEYWORD}")
18 ENDIF(C_HAS_${KEYWORD})
19 ENDIF(NOT DEFINED C_INLINE)
21 IF(NOT DEFINED C_INLINE)
22 ADD_DEFINITIONS("-Dinline=")
23 ENDIF(NOT DEFINED C_INLINE)