From f3b1ea3d955d01e0f720acc9ec0565046658df09 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 3 Oct 2010 18:23:38 +0200 Subject: [PATCH] Changed: #1111 Added commands for Mac OS --- code/CMakeModules/CheckDepends.cmake | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/code/CMakeModules/CheckDepends.cmake b/code/CMakeModules/CheckDepends.cmake index 3218e3614..f298b566a 100644 --- a/code/CMakeModules/CheckDepends.cmake +++ b/code/CMakeModules/CheckDepends.cmake @@ -16,7 +16,14 @@ MACRO(CHECK_UNDEFINED_SYMBOL MYLIBRARY SYMBOL SYMBOL_FOUND) IF(WIN32) # Always TRUE under Windows because we are using static libraries ELSEIF(APPLE) - # TODO: use otool to detect if a library is using a symbol + SET(CMAKE_OTOOL otool) + IF(CMAKE_OTOOL) + # Use otool to check if a library is using an external symbol + EXEC_PROGRAM(${CMAKE_OTOOL} ARGS "-Rv ${${MYLIBRARY}} | grep ${SYMBOL}" OUTPUT_VARIABLE OTOOL_SYMBOL) + IF(NOT OTOOL_SYMBOL MATCHES "undefined") + SET(${SYMBOL_FOUND} FALSE) + ENDIF(NOT OTOOL_SYMBOL MATCHES "undefined") + ENDIF(CMAKE_OTOOL) ELSEIF(UNIX) IF(CMAKE_OBJDUMP) # Use objdump to check if a library is using an external symbol @@ -43,10 +50,19 @@ MACRO(CHECK_LINKED_LIBRARY MYLIBRARY OTHERLIBRARY LIBRARY_FOUND) IF(WIN32) # Always FALSE under Windows because we are using static libraries ELSEIF(APPLE) - # TODO: use otool to detect if a library is using a symbol + SET(CMAKE_OTOOL otool) + IF(CMAKE_OTOOL) + # Use otool to check if a library is linked to another library + GET_FILENAME_COMPONENT(LIBNAME ${${OTHERLIBRARY}} NAME) + EXEC_PROGRAM(${CMAKE_OTOOL} ARGS "-L ${${MYLIBRARY}} | grep ${${OTHERLIBRARY}}" OUTPUT_VARIABLE OTOOL_LIBRARY) + IF(NOT OTOOL_LIBRARY MATCHES "${LIBNAME}") + SET(${LIBRARY_FOUND} FALSE) + ENDIF(NOT OTOOL_LIBRARY MATCHES "${LIBNAME}") + ENDIF(CMAKE_OTOOL) ELSEIF(UNIX) IF(CMAKE_OBJDUMP) GET_FILENAME_COMPONENT(LIBNAME ${${OTHERLIBRARY}} NAME) + # TODO: under Solaris use dump -Lv # Use objdump to check if a library is linked to another library EXEC_PROGRAM(${CMAKE_OBJDUMP} ARGS "-p ${${MYLIBRARY}} | grep ${LIBNAME}" OUTPUT_VARIABLE OBJDUMP_LIBRARY) IF(OBJDUMP_LIBRARY MATCHES "NEEDED")