~sergei.glushchenko/+junk/page-scan-hack

« back to all changes in this revision

Viewing changes to src/libarchive/build/cmake/CheckFuncs.cmake

merge parallel compression branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Check if the system has the specified function; treat glibc "stub"
 
2
# functions as nonexistent:
 
3
# CHECK_FUNCTION_EXISTS_GLIBC (FUNCTION FUNCVAR)
 
4
#
 
5
#  FUNCTION - the function(s) where the prototype should be declared
 
6
#  FUNCVAR - variable to define if the function does exist
 
7
#
 
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.
 
13
#
 
14
# The following variables may be set before calling this macro to
 
15
# modify the way the check is run:
 
16
#
 
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
 
21
#
 
22
# Redistribution and use is allowed according to the terms of the BSD license.
 
23
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
24
 
 
25
INCLUDE(CheckFunctionExists)
 
26
GET_FILENAME_COMPONENT(_selfdir_CheckFunctionExistsGlibc
 
27
         "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
28
 
 
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)
 
35
     TRY_COMPILE(__stub
 
36
       ${CMAKE_CURRENT_BINARY_DIR}
 
37
       ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c
 
38
       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
 
39
       CMAKE_FLAGS
 
40
       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
 
41
       "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}")
 
42
     IF (__stub)
 
43
       SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}")
 
44
     ELSE (__stub)
 
45
       CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}")
 
46
     ENDIF (__stub)
 
47
  ENDIF(NOT DEFINED ${_FUNCVAR})
 
48
ENDMACRO (CHECK_FUNCTION_EXISTS_GLIBC)
 
49