Mercurial > audio-send
diff cmake/CheckSharedFunctionExists.cmake @ 0:f9476ff7637e
initial forking of open-al to create multiple listeners
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 13:02:31 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/cmake/CheckSharedFunctionExists.cmake Tue Oct 25 13:02:31 2011 -0700 1.3 @@ -0,0 +1,92 @@ 1.4 +# - Check if a symbol exists as a function, variable, or macro 1.5 +# CHECK_SYMBOL_EXISTS(<symbol> <files> <variable>) 1.6 +# 1.7 +# Check that the <symbol> is available after including given header 1.8 +# <files> and store the result in a <variable>. Specify the list 1.9 +# of files in one argument as a semicolon-separated list. 1.10 +# 1.11 +# If the header files define the symbol as a macro it is considered 1.12 +# available and assumed to work. If the header files declare the 1.13 +# symbol as a function or variable then the symbol must also be 1.14 +# available for linking. If the symbol is a type or enum value 1.15 +# it will not be recognized (consider using CheckTypeSize or 1.16 +# CheckCSourceCompiles). 1.17 +# 1.18 +# The following variables may be set before calling this macro to 1.19 +# modify the way the check is run: 1.20 +# 1.21 +# CMAKE_REQUIRED_FLAGS = string of compile command line flags 1.22 +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 1.23 +# CMAKE_REQUIRED_INCLUDES = list of include directories 1.24 +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link 1.25 + 1.26 +#============================================================================= 1.27 +# Copyright 2003-2011 Kitware, Inc. 1.28 +# 1.29 +# Distributed under the OSI-approved BSD License (the "License"); 1.30 +# see accompanying file Copyright.txt for details. 1.31 +# 1.32 +# This software is distributed WITHOUT ANY WARRANTY; without even the 1.33 +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1.34 +# See the License for more information. 1.35 +#============================================================================= 1.36 +# (To distribute this file outside of CMake, substitute the full 1.37 +# License text for the above reference.) 1.38 + 1.39 +MACRO(CHECK_SHARED_FUNCTION_EXISTS SYMBOL FILES LIBRARY LOCATION VARIABLE) 1.40 + IF("${VARIABLE}" MATCHES "^${VARIABLE}$") 1.41 + SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") 1.42 + SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) 1.43 + IF(CMAKE_REQUIRED_LIBRARIES) 1.44 + SET(CHECK_SYMBOL_EXISTS_LIBS 1.45 + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES};${LIBRARY}") 1.46 + ELSE(CMAKE_REQUIRED_LIBRARIES) 1.47 + SET(CHECK_SYMBOL_EXISTS_LIBS 1.48 + "-DLINK_LIBRARIES:STRING=${LIBRARY}") 1.49 + ENDIF(CMAKE_REQUIRED_LIBRARIES) 1.50 + IF(CMAKE_REQUIRED_INCLUDES) 1.51 + SET(CMAKE_SYMBOL_EXISTS_INCLUDES 1.52 + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") 1.53 + ELSE(CMAKE_REQUIRED_INCLUDES) 1.54 + SET(CMAKE_SYMBOL_EXISTS_INCLUDES) 1.55 + ENDIF(CMAKE_REQUIRED_INCLUDES) 1.56 + FOREACH(FILE ${FILES}) 1.57 + SET(CMAKE_CONFIGURABLE_FILE_CONTENT 1.58 + "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") 1.59 + ENDFOREACH(FILE) 1.60 + SET(CMAKE_CONFIGURABLE_FILE_CONTENT 1.61 + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n cmakeRequireSymbol(0,&${SYMBOL});\n return 0;\n}\n") 1.62 + 1.63 + CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" 1.64 + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" @ONLY) 1.65 + 1.66 + MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY}") 1.67 + TRY_COMPILE(${VARIABLE} 1.68 + ${CMAKE_BINARY_DIR} 1.69 + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c 1.70 + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} 1.71 + CMAKE_FLAGS 1.72 + -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} 1.73 + -DLINK_DIRECTORIES:STRING=${LOCATION} 1.74 + "${CHECK_SYMBOL_EXISTS_LIBS}" 1.75 + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" 1.76 + OUTPUT_VARIABLE OUTPUT) 1.77 + IF(${VARIABLE}) 1.78 + MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY} - found") 1.79 + SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL} in ${LIBRARY}") 1.80 + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 1.81 + "Determining if the ${SYMBOL} " 1.82 + "exist in ${LIBRARY} passed with the following output:\n" 1.83 + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" 1.84 + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") 1.85 + ELSE(${VARIABLE}) 1.86 + MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY} - not found.") 1.87 + SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL} in ${LIBRARY}") 1.88 + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 1.89 + "Determining if the ${SYMBOL} " 1.90 + "exist in ${LIBRARY} failed with the following output:\n" 1.91 + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" 1.92 + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") 1.93 + ENDIF(${VARIABLE}) 1.94 + ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") 1.95 +ENDMACRO(CHECK_SHARED_FUNCTION_EXISTS)