cmocka: fix doxygen comment for assert_not_in_range()
[obnox/cmocka.git] / ConfigureChecks.cmake
1 include(CheckIncludeFile)
2 include(CheckSymbolExists)
3 include(CheckFunctionExists)
4 include(CheckLibraryExists)
5 include(CheckTypeSize)
6 include(CheckCXXSourceCompiles)
7 include(TestBigEndian)
8
9 set(PACKAGE ${APPLICATION_NAME})
10 set(VERSION ${APPLICATION_VERSION})
11 set(DATADIR ${DATA_INSTALL_DIR})
12 set(LIBDIR ${LIB_INSTALL_DIR})
13 set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
14 set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
15
16 set(BINARYDIR ${CMAKE_BINARY_DIR})
17 set(SOURCEDIR ${CMAKE_SOURCE_DIR})
18
19 function(COMPILER_DUMPVERSION _OUTPUT_VERSION)
20     # Remove whitespaces from the argument.
21     # This is needed for CC="ccache gcc" cmake ..
22     string(REPLACE " " "" _C_COMPILER_ARG "${CMAKE_C_COMPILER_ARG1}")
23
24     execute_process(
25         COMMAND
26             ${CMAKE_C_COMPILER} ${_C_COMPILER_ARG} -dumpversion
27         OUTPUT_VARIABLE _COMPILER_VERSION
28     )
29
30     string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
31         _COMPILER_VERSION ${_COMPILER_VERSION})
32
33     set(${_OUTPUT_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
34 endfunction()
35
36 if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
37     compiler_dumpversion(GNUCC_VERSION)
38     if (NOT GNUCC_VERSION EQUAL 34)
39         check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
40     endif (NOT GNUCC_VERSION EQUAL 34)
41 endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
42
43 # DEFINITIONS
44 if (SOLARIS)
45     add_definitions(-D__EXTENSIONS__)
46 endif (SOLARIS)
47
48 # HEADER FILES
49 check_include_file(assert.h HAVE_ASSERT_H)
50 check_include_file(inttypes.h HAVE_INTTYPES_H)
51 check_include_file(malloc.h HAVE_MALLOC_H)
52 check_include_file(memory.h HAVE_MEMORY_H)
53 check_include_file(setjmp.h HAVE_SETJMP_H)
54 check_include_file(signal.h HAVE_SIGNAL_H)
55 check_include_file(stdarg.h HAVE_STDARG_H)
56 check_include_file(stddef.h HAVE_STDDEF_H)
57 check_include_file(stdint.h HAVE_STDINT_H)
58 check_include_file(stdio.h HAVE_STDIO_H)
59 check_include_file(stdlib.h HAVE_STDLIB_H)
60 check_include_file(string.h HAVE_STRING_H)
61 check_include_file(strings.h HAVE_STRINGS_H)
62 check_include_file(sys/stat.h HAVE_SYS_STAT_H)
63 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
64 check_include_file(unistd.h HAVE_UNISTD_H)
65
66
67 # FUNCTIONS
68 check_function_exists(calloc HAVE_CALLOC)
69 check_function_exists(exit HAVE_EXIT)
70 check_function_exists(fprintf HAVE_FPRINTF)
71 check_function_exists(free HAVE_FREE)
72 check_function_exists(longjmp HAVE_LONGJMP)
73 check_function_exists(malloc HAVE_MALLOC)
74 check_function_exists(memcpy HAVE_MEMCPY)
75 check_function_exists(memset HAVE_MEMSET)
76 check_function_exists(printf HAVE_PRINTF)
77 check_function_exists(setjmp HAVE_SETJMP)
78 check_function_exists(signal HAVE_SIGNAL)
79 check_function_exists(strsignal HAVE_STRSIGNAL)
80 check_function_exists(sprintf HAVE_SNPRINTF)
81 check_function_exists(strcmp HAVE_STRCMP)
82 check_function_exists(vsnprintf HAVE_VSNPRINTF)
83
84 if (WIN32)
85     check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
86     check_function_exists(_vsnprintf HAVE__VSNPRINTF)
87     check_function_exists(_snprintf HAVE__SNPRINTF)
88     check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
89 endif (WIN32)
90
91 set(CMOCKA_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "cmocka required system libraries")
92
93 # OPTIONS
94
95 # ENDIAN
96 if (NOT WIN32)
97     set(WORDS_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
98     test_big_endian(WORDS_BIGENDIAN)
99 endif (NOT WIN32)