You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OvLinkBoostLib.cmake 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # Win32 only
  3. #
  4. # This concoction mainly exists to locate the boost libraries on WIN32 in the case where our dependency/ folder has only a
  5. # truncated version of boost and we cannot use find_package(). The background story is that we wish to link explicitly
  6. # instead of using automatic linking and specifying a generic boost path to linker before each project definition.
  7. #
  8. # The downside of this is that it assumes the boost library names to have a particular format and only works for VC90/VC100
  9. #
  10. # Function: Links specified boost library defined by COMPONENT and BOOST_VERSION to PROJECT_NAME.
  11. #
  12. FUNCTION(OV_LINK_BOOST_LIB BOOST_COMPONENT BOOST_VERSION)
  13. GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_BOOST_${BOOST_COMPONENT})
  14. IF(WIN32)
  15. SET(LIB_BOOST "unknown-platform-NOTFOUND")
  16. SET(LIB_BOOST_DEBUG "unknown-platform-NOTFOUND")
  17. STRING(REGEX MATCH "vc100.*" MSVC_VER100 ${MSVC_SERVICE_PACK})
  18. IF(MSVC_VER100)
  19. SET(LIB_BOOST "libboost_${BOOST_COMPONENT}-vc100-mt-${BOOST_VERSION}.lib")
  20. SET(LIB_BOOST_DEBUG "libboost_${BOOST_COMPONENT}-vc100-mt-gd-${BOOST_VERSION}.lib")
  21. ENDIF(MSVC_VER100)
  22. STRING(REGEX MATCH "vc120.*" MSVC_VER120 ${MSVC_SERVICE_PACK})
  23. IF(MSVC_VER120)
  24. SET(LIB_BOOST "libboost_${BOOST_COMPONENT}-vc120-mt-${BOOST_VERSION}.lib")
  25. SET(LIB_BOOST_DEBUG "libboost_${BOOST_COMPONENT}-vc120-mt-gd-${BOOST_VERSION}.lib")
  26. ENDIF(MSVC_VER120)
  27. SET(LIB_BOOST_PATH "-NOTFOUND")
  28. FIND_LIBRARY(LIB_BOOST_PATH NAMES ${LIB_BOOST} PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES boost/lib NO_DEFAULT_PATH)
  29. SET(LIB_BOOST_DEBUG_PATH "-NOTFOUND")
  30. FIND_LIBRARY(LIB_BOOST_DEBUG_PATH NAMES ${LIB_BOOST_DEBUG} PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES boost/lib NO_DEFAULT_PATH)
  31. IF(LIB_BOOST_PATH AND LIB_BOOST_DEBUG_PATH)
  32. OV_PRINT(OV_PRINTED " Found Boost ${BOOST_COMPONENT} libraries ...")
  33. ELSE(LIB_BOOST_PATH AND LIB_BOOST_DEBUG_PATH)
  34. OV_PRINT(OV_PRINTED " FAILED to find all Boost ${BOOST_COMPONENT} libraries ...")
  35. ENDIF(LIB_BOOST_PATH AND LIB_BOOST_DEBUG_PATH)
  36. IF(LIB_BOOST_PATH)
  37. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_BOOST_PATH}")
  38. TARGET_LINK_LIBRARIES(${PROJECT_NAME} optimized ${LIB_BOOST_PATH})
  39. ELSE(LIB_BOOST_PATH)
  40. MESSAGE(STATUS " FAILED to find boost lib ${LIB_BOOST}")
  41. ENDIF(LIB_BOOST_PATH)
  42. IF(LIB_BOOST_DEBUG_PATH)
  43. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_BOOST_DEBUG_PATH}")
  44. TARGET_LINK_LIBRARIES(${PROJECT_NAME} debug ${LIB_BOOST_DEBUG_PATH})
  45. ELSE(LIB_BOOST_DEBUG_PATH)
  46. MESSAGE(STATUS " FAILED to find boost debug lib ${LIB_BOOST_DEBUG}")
  47. ENDIF(LIB_BOOST_DEBUG_PATH)
  48. ENDIF(WIN32)
  49. SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_BOOST_${BOOST_COMPONENT} "Yes")
  50. ENDFUNCTION(OV_LINK_BOOST_LIB)