Blame build/cmake/CheckFuncs.cmake

Packit Service 1d0348
# Check if the system has the specified function; treat glibc "stub"
Packit Service 1d0348
# functions as nonexistent:
Packit Service 1d0348
# CHECK_FUNCTION_EXISTS_GLIBC (FUNCTION FUNCVAR)
Packit Service 1d0348
#
Packit Service 1d0348
#  FUNCTION - the function(s) where the prototype should be declared
Packit Service 1d0348
#  FUNCVAR - variable to define if the function does exist
Packit Service 1d0348
#
Packit Service 1d0348
# In particular, this understands the glibc convention of
Packit Service 1d0348
# defining macros __stub_XXXX or __stub___XXXX if the function
Packit Service 1d0348
# does appear in the library but is merely a stub that does nothing.
Packit Service 1d0348
# By detecting this case, we can select alternate behavior on
Packit Service 1d0348
# platforms that don't support this functionality.
Packit Service 1d0348
#
Packit Service 1d0348
# The following variables may be set before calling this macro to
Packit Service 1d0348
# modify the way the check is run:
Packit Service 1d0348
#
Packit Service 1d0348
#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
Packit Service 1d0348
#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
Packit Service 1d0348
#  CMAKE_REQUIRED_INCLUDES = list of include directories
Packit Service 1d0348
# Copyright (c) 2009, Michihiro NAKAJIMA
Packit Service 1d0348
#
Packit Service 1d0348
# Redistribution and use is allowed according to the terms of the BSD license.
Packit Service 1d0348
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
Packit Service 1d0348
Packit Service 1d0348
INCLUDE(CheckFunctionExists)
Packit Service 1d0348
GET_FILENAME_COMPONENT(_selfdir_CheckFunctionExistsGlibc
Packit Service 1d0348
	 "${CMAKE_CURRENT_LIST_FILE}" PATH)
Packit Service 1d0348
Packit Service 1d0348
MACRO (CHECK_FUNCTION_EXISTS_GLIBC _FUNC _FUNCVAR)
Packit Service 1d0348
   IF(NOT DEFINED ${_FUNCVAR})
Packit Service 1d0348
     SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}")
Packit Service 1d0348
     SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}")
Packit Service 1d0348
     CONFIGURE_FILE( ${_selfdir_CheckFunctionExistsGlibc}/CheckFuncs_stub.c.in
Packit Service 1d0348
       ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE)
Packit Service 1d0348
     TRY_COMPILE(__stub
Packit Service 1d0348
       ${CMAKE_CURRENT_BINARY_DIR}
Packit Service 1d0348
       ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c
Packit Service 1d0348
       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
Packit Service 1d0348
       CMAKE_FLAGS
Packit Service 1d0348
       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
Packit Service 1d0348
       "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}")
Packit Service 1d0348
     IF (__stub)
Packit Service 1d0348
       SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}")
Packit Service 1d0348
     ELSE (__stub)
Packit Service 1d0348
       CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}")
Packit Service 1d0348
     ENDIF (__stub)
Packit Service 1d0348
  ENDIF(NOT DEFINED ${_FUNCVAR})
Packit Service 1d0348
ENDMACRO (CHECK_FUNCTION_EXISTS_GLIBC)
Packit Service 1d0348