Initial attempt to check if library exists

This commit is contained in:
Andy Cedilnik 2002-09-24 16:36:56 -04:00
parent 8d14221f7e
commit 3697ad6dc7
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#
# Check if the function exists.
#
# CHECK_LIBRARY_EXISTS - macro which checks if the function exists
# FUNCTION - the name of the function
# VARIABLE - variable to store the result
#
MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
SET(CHECK_LIBRARY_EXISTS_LIBRARY ${LIBRARY})
SET(CHECK_LIBRARY_EXISTS_FUNCTION ${FUNCTION})
SET(CHECK_LIBRARY_EXISTS_LOCATION ${LOCATION})
SET(CHECK_LIBRARY_EXISTS_VARIABLE ${VARIABLE})
SET(CHECK_LIBRARY_EXISTS_SOURCE ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckLibraryExists.lists.in
${PROJECT_BINARY_DIR}/CMakeTmp/CheckLibraryExists/CMakeLists.txt
IMMEDIATE)
TRY_COMPILE(${VARIABLE}
${PROJECT_BINARY_DIR}/CMakeTmp/CheckLibraryExists
${PROJECT_BINARY_DIR}/CMakeTmp/CheckLibraryExists
CHECK_LIBRARY_EXISTS OUTPUT_VARIABLE OUTPUT)
IF(NOT ${VARIABLE})
WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log
"Determining if the function ${FUNCTION} exists failed with the following output:\n"
"${OUTPUT}\n")
ENDIF(NOT ${VARIABLE})
ENDMACRO(CHECK_LIBRARY_EXISTS)

View File

@ -0,0 +1,8 @@
PROJECT(CHECK_LIBRARY_EXISTS)
ADD_DEFINITIONS(-DCHECK_FUNCTION_EXISTS=${CHECK_LIBRARY_EXISTS_FUNCTION})
LINK_DIRECTORIES(${CHECK_LIBRARY_EXISTS_LOCATION})
ADD_EXECUTABLE(CheckLibraryExists ${CHECK_LIBRARY_EXISTS_SOURCE})
TARGET_LINK_LIBRARIES(CheckLibraryExists ${CHECK_LIBRARY_EXISTS_LIBRARY})