endif()
endif()
+if(MSVC)
+ set(INLINE_OPTIONS "__inline;inline")
+else()
+ set(INLINE_OPTIONS "__inline__;inline")
+endif()
option(FORCE_INLINE "Force function inlining" TRUE)
boolean_number(FORCE_INLINE)
if(FORCE_INLINE)
if(MSVC)
- set(INLINE "__forceinline")
- check_c_source_compiles("__forceinline void foo(void) {} int main(void) { foo(); }"
- FORCE_INLINE_WORKS)
+ list(INSERT INLINE_OPTIONS 0 "__forceinline")
else()
- set(INLINE "inline __attribute__((always_inline))")
- check_c_source_compiles("static inline __attribute__((always_inline)) void foo(void) {} int main(void) { foo(); }"
- FORCE_INLINE_WORKS)
+ list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))")
+ list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))")
endif()
endif()
-if(NOT FORCE_INLINE OR NOT FORCE_INLINE_WORKS)
- if(MSVC)
- set(INLINE "__inline")
- check_c_source_compiles("__inline void foo(void) {} int main(void) { foo(); }"
- INLINE_WORKS)
- else()
- set(INLINE "__inline__")
- check_c_source_compiles("static __inline__ void foo(void) {} int main(void) { foo(); }"
- INLINE_WORKS)
- endif()
- if(NOT INLINE_WORKS)
- set(INLINE "inline")
- check_c_source_compiles("static inline void foo(void) {} int main(void) { foo(); }"
- C99_INLINE_WORKS)
- if(NOT C99_INLINE_WORKS)
- message(FATAL_ERROR "Could not determine how to inline functions.")
- endif()
+foreach(inline ${INLINE_OPTIONS})
+ check_c_source_compiles("${inline} static void foo(void) {} int main(void) { foo(); }"
+ INLINE_WORKS)
+ if(INLINE_WORKS)
+ set(INLINE ${inline})
+ break()
endif()
+endforeach()
+if(NOT INLINE_WORKS)
+ message(FATAL_ERROR "Could not determine how to inline functions.")
endif()
message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")