Ticket #32302: patch-CMake_Packages_FindOGRE.cmake.diff

File patch-CMake_Packages_FindOGRE.cmake.diff, 2.5 KB (added by marin.saric@…, 13 years ago)
  • CMake/Packages/FindOGRE.cmake

    old new  
    6868  set(OGRE_LIB_SUFFIX "")
    6969endif ()
    7070
     71if (APPLE AND OGRE_STATIC)
     72  # If OGRE_STATIC, force CMake to select static versions
     73  # of dependent libraries on MacOS X
     74  SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
     75  SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.framework")
     76endif(APPLE AND OGRE_STATIC)
     77
    7178
    7279set(OGRE_LIBRARY_NAMES "OgreMain${OGRE_LIB_SUFFIX}")
    7380get_debug_names(OGRE_LIBRARY_NAMES)
     
    144151# try to locate Ogre via pkg-config
    145152use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}")
    146153
    147 if(NOT OGRE_BUILD_PLATFORM_IPHONE)
    148   # try to find framework on OSX
    149   findpkg_framework(OGRE)
     154if(APPLE AND NOT OGRE_BUILD_PLATFORM_IPHONE)
     155  if (NOT OGRE_STATIC)
     156    # try to find framework on OSX
     157    findpkg_framework(OGRE)
     158  endif()
    150159else()
    151160        set(OGRE_LIBRARY_FWK "")
    152161endif()
     
    258267    endif ()
    259268  endif ()
    260269
    261   set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES}
    262     ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES}
    263     ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB}
    264     ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES})
     270  list(APPEND OGRE_LIBRARIES
     271    ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES}
     272    ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES})
    265273
    266274  if (NOT ZLIB_FOUND OR NOT ZZip_FOUND)
    267275    set(OGRE_DEPS_FOUND FALSE)
     
    274282  endif ()
    275283  if (UNIX AND NOT APPLE)
    276284        if (NOT X11_FOUND)
    277       set(OGRE_DEPS_FOUND FALSE)
     285          set(OGRE_DEPS_FOUND FALSE)
    278286        endif ()
     287
     288        list(APPEND OGRE_LIBRARIES
     289          ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB})
    279290  endif ()
    280291
     292  if (APPLE)
     293    list(APPEND OGRE_LIBRARIES
     294      ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES})
     295      # If FreeType is found on MacOS X, it has a hidden
     296      # dependency on libbzip2
     297      FIND_PACKAGE(BZip2 REQUIRED)
     298      list(APPEND OGRE_LIBRARIES ${BZIP2_LIBRARIES})
     299  endif()
     300
    281301  if (OGRE_CONFIG_THREADS)
    282302    if (OGRE_CONFIG_THREAD_PROVIDER EQUAL 1)
    283303      find_package(Boost COMPONENTS thread QUIET)
     
    532552find_path(OGRE_MEDIA_DIR NAMES packs/cubemapsJS.zip HINTS ${OGRE_MEDIA_SEARCH_PATH}
    533553  PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX})
    534554
     555if (APPLE AND OGRE_STATIC)
     556  # Restore old CMAKE_FIND_LIBRARY_SUFFIXES on MacOS X
     557  SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
     558endif(APPLE AND OGRE_STATIC)