diff options
-rw-r--r-- | cmake/CheckAlwaysInline.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmake/CheckAlwaysInline.cmake b/cmake/CheckAlwaysInline.cmake new file mode 100644 index 000000000..ab5ceb0ac --- /dev/null +++ b/cmake/CheckAlwaysInline.cmake @@ -0,0 +1,44 @@ +# This module checks if the C++ compiler supports +# __attribute__((always_inline)). +# +# If yes, _RESULT is set to __attribute__((always_inline)). +# If no, _RESULT is set to empty value. +# +# Copyright Benoit Jacob 2007 <jacob@math.jussieu.fr> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file in +# kdelibs/cmake/modules. + +INCLUDE(CheckCXXSourceCompiles) + +MACRO (CHECK_ALWAYS_INLINE _RESULT) + +SET(_CHECK_attribute_always_inline_SRC " + +#ifdef __GNUC__ +# define ALL_IS_WELL +#endif + +#ifdef __INTEL_COMPILER +# if (__INTEL_COMPILER == 800) || (__INTEL_COMPILER > 800) +# define ALL_IS_WELL +# endif +#endif + +#ifndef ALL_IS_WELL +# error I guess your compiler doesn't support __attribute__((always_inline)) +#endif + +int main(int argc, char *argv[]) { return 0; } +") + +CHECK_CXX_SOURCE_COMPILES("${_CHECK_attribute_always_inline_SRC}" + HAVE_attribute_always_inline) +IF(HAVE_attribute_always_inline) + SET(${_RESULT} "__attribute__((always_inline))") +ELSE(HAVE_attribute_always_inline) + SET(${_RESULT} ) # attribute always_inline unsupported +ENDIF(HAVE_attribute_always_inline) + +ENDMACRO (CHECK_ALWAYS_INLINE) |