1
# Check if the system has the specified function; treat glibc "stub"
2
# functions as nonexistent:
3
# CHECK_FUNCTION_EXISTS_GLIBC (FUNCTION FUNCVAR)
5
# FUNCTION - the function(s) where the prototype should be declared
6
# FUNCVAR - variable to define if the function does exist
8
# In particular, this understands the glibc convention of
9
# defining macros __stub_XXXX or __stub___XXXX if the function
10
# does appear in the library but is merely a stub that does nothing.
11
# By detecting this case, we can select alternate behavior on
12
# platforms that don't support this functionality.
14
# The following variables may be set before calling this macro to
15
# modify the way the check is run:
17
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
18
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
19
# CMAKE_REQUIRED_INCLUDES = list of include directories
20
# Copyright (c) 2009, Michihiro NAKAJIMA
22
# Redistribution and use is allowed according to the terms of the BSD license.
23
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
25
INCLUDE(CheckFunctionExists)
26
GET_FILENAME_COMPONENT(_selfdir_CheckFunctionExistsGlibc
27
"${CMAKE_CURRENT_LIST_FILE}" PATH)
29
MACRO (CHECK_FUNCTION_EXISTS_GLIBC _FUNC _FUNCVAR)
30
IF(NOT DEFINED ${_FUNCVAR})
31
SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}")
32
SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}")
33
CONFIGURE_FILE( ${_selfdir_CheckFunctionExistsGlibc}/CheckFuncs_stub.c.in
34
${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE)
36
${CMAKE_CURRENT_BINARY_DIR}
37
${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c
38
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
40
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
41
"${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}")
43
SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}")
45
CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}")
47
ENDIF(NOT DEFINED ${_FUNCVAR})
48
ENDMACRO (CHECK_FUNCTION_EXISTS_GLIBC)