From 6d5c4370450fa34afb754ca2fdef79ee71ab9d99 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Wed, 1 Jan 2003 15:02:20 -0500 Subject: [PATCH] Add a way to add custom libraries to the mix --- Modules/CheckFunctionExists.cmake | 5 +++++ Modules/CheckLibraryExists.cmake | 7 ++++++- Modules/CheckTypeSize.cmake | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 1ab1ad372..0e830f672 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -10,10 +10,15 @@ MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") SET(MACRO_CHECK_FUNCTION_DEFINITIONS -DCHECK_FUNCTION_EXISTS=${FUNCTION}) MESSAGE(STATUS "Looking for ${FUNCTION}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckFunctionExists.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index ea92fab5b..9eb48af9b 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -10,13 +10,18 @@ MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION -DCHECK_FUNCTION_EXISTS=${FUNCTION}) MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + SET(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_LIBRARY_EXISTS_LIBRARIES + ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}) + ENDIF(CMAKE_REQUIRED_LIBRARIES) TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckFunctionExists.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION} -DLINK_DIRECTORIES:STRING=${LOCATION} - -DLINK_LIBRARIES:STRING=${LIBRARY} + -DLINK_LIBRARIES:STRING=${CHECK_LIBRARY_EXISTS_LIBRARIES} OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 35dcaaa81..306f1a14c 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -17,10 +17,15 @@ MACRO(CHECK_TYPE_SIZE TYPE VARIABLE) SET(MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -DHAVE_STDINT_H") ENDIF(HAVE_STDINT_H) MESSAGE(STATUS "Check size of ${TYPE}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_TYPE_SIZE_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) TRY_RUN(${VARIABLE} HAVE_${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckTypeSize.c CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} + ${CHECK_TYPE_SIZE_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT) IF(HAVE_${VARIABLE}) MESSAGE(STATUS "Check size of ${TYPE} - done")