]> git.sesse.net Git - vlc/blob - extras/buildsystem/cmake/include/vlc_test_inline.cmake
cmake: Don't use poll() on Mac OS X, as it can't poll a tty properly.
[vlc] / extras / buildsystem / cmake / include / vlc_test_inline.cmake
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=).
6
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;}"
14         C_HAS_${KEYWORD})
15      IF(C_HAS_${KEYWORD})
16        SET(C_INLINE TRUE)
17        ADD_DEFINITIONS("-Dinline=${KEYWORD}")
18      ENDIF(C_HAS_${KEYWORD})
19    ENDIF(NOT DEFINED C_INLINE)
20 ENDFOREACH(KEYWORD)
21 IF(NOT DEFINED C_INLINE)
22    ADD_DEFINITIONS("-Dinline=")
23 ENDIF(NOT DEFINED C_INLINE)