FindGLBINDING.cmake 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # GLBINDING_FOUND
  2. # GLBINDING_LIBRARIES
  3. # GLBINDING_INCLUDE_DIRS
  4. # GLBINDING_LIBRARY
  5. # GLBINDING_LIBRARY_RELEASE
  6. # GLBINDING_LIBRARY_DEBUG
  7. # GLBINDING_INCLUDE_DIR
  8. # GLBINDING_BINARIES (win32 only)
  9. # GLBINDING_BINARY_RELEASE (win32 only)
  10. # GLBINDING_BINARY_DEBUG (win32 only)
  11. macro (find LIB_NAME HEADER)
  12. set(HINT_PATHS ${ARGN})
  13. if (${LIB_NAME} STREQUAL "glbinding")
  14. set(LIB_NAME_UPPER GLBINDING)
  15. set(LIBNAME glbinding)
  16. else()
  17. string(TOUPPER GLBINDING_${LIB_NAME} LIB_NAME_UPPER)
  18. set(LIBNAME glbinding${LIB_NAME})
  19. endif()
  20. find_path(${LIB_NAME_UPPER}_INCLUDE_DIR ${HEADER}
  21. ${ENVGLBINDING_DIR}/include
  22. ${ENVGLBINDING_DIR}/source/${LIBNAME}/include
  23. ${GLBINDING_DIR}/include
  24. ${GLBINDING_DIR}/source/${LIBNAME}/include
  25. ${ENVPROGRAMFILES}/glbinding/include
  26. /usr/include
  27. /usr/local/include
  28. /sw/include
  29. /opt/local/include
  30. DOC "The directory where ${header} resides")
  31. find_library(${LIB_NAME_UPPER}_LIBRARY_RELEASE
  32. NAMES ${LIBNAME}
  33. PATHS ${HINT_PATHS}
  34. DOC "The ${LIB_NAME} library")
  35. find_library(${LIB_NAME_UPPER}_LIBRARY_DEBUG
  36. NAMES ${LIBNAME}d
  37. PATHS ${HINT_PATHS}
  38. DOC "The ${LIB_NAME} debug library")
  39. if(${LIB_NAME_UPPER}_LIBRARY_RELEASE AND ${LIB_NAME_UPPER}_LIBRARY_DEBUG)
  40. set(${LIB_NAME_UPPER}_LIBRARY "optimized" ${${LIB_NAME_UPPER}_LIBRARY_RELEASE} "debug" ${${LIB_NAME_UPPER}_LIBRARY_DEBUG})
  41. elseif(${LIB_NAME_UPPER}_LIBRARY_RELEASE)
  42. set(${LIB_NAME_UPPER}_LIBRARY ${${LIB_NAME_UPPER}_LIBRARY_RELEASE})
  43. elseif(${LIB_NAME_UPPER}_LIBRARY_DEBUG)
  44. set(${LIB_NAME_UPPER}_LIBRARY ${${LIB_NAME_UPPER}_LIBRARY_DEBUG})
  45. endif()
  46. list(APPEND GLBINDING_INCLUDE_DIRS ${${LIB_NAME_UPPER}_INCLUDE_DIR})
  47. list(APPEND GLBINDING_LIBRARIES ${${LIB_NAME_UPPER}_LIBRARY})
  48. # DEBUG
  49. # message("${LIB_NAME_UPPER}_INCLUDE_DIR = ${${LIB_NAME_UPPER}_INCLUDE_DIR}")
  50. # message("${LIB_NAME_UPPER}_LIBRARY_RELEASE = ${${LIB_NAME_UPPER}_LIBRARY_RELEASE}")
  51. # message("${LIB_NAME_UPPER}_LIBRARY_DEBUG = ${${LIB_NAME_UPPER}_LIBRARY_DEBUG}")
  52. # message("${LIB_NAME_UPPER}_LIBRARY = ${${LIB_NAME_UPPER}_LIBRARY}")
  53. endmacro()
  54. if(CMAKE_CURRENT_LIST_FILE)
  55. get_filename_component(GLBINDING_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
  56. endif()
  57. file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ENVPROGRAMFILES)
  58. file(TO_CMAKE_PATH "$ENV{GLBINDING_DIR}" ENVGLBINDING_DIR)
  59. set(GLBINDING_INCLUDE_DIRS "")
  60. set(GLBINDING_LIBRARIES "")
  61. set(LIB_PATHS
  62. ${GLBINDING_DIR}/build
  63. ${GLBINDING_DIR}/build/Release
  64. ${GLBINDING_DIR}/build/Debug
  65. ${GLBINDING_DIR}/build-release
  66. ${GLBINDING_DIR}/build-debug
  67. ${ENVGLBINDING_DIR}/lib
  68. ${GLBINDING_DIR}/lib
  69. ${ENVPROGRAMFILES}/glbinding/lib
  70. /usr/lib
  71. /usr/local/lib
  72. /sw/lib
  73. /opt/local/lib
  74. /usr/lib64
  75. /usr/local/lib64
  76. /sw/lib64
  77. /opt/local/lib64
  78. )
  79. find(glbinding glbinding/glbinding_api.h ${LIB_PATHS})
  80. if (GLBINDING_LIBRARY AND WIN32)
  81. set(GLBINDING_BINARIES "")
  82. find_file(GLBINDING_BINARY_RELEASE
  83. NAMES glbinding.dll
  84. PATHS
  85. ${GLBINDING_DIR}/bin
  86. ${GLBINDING_DIR}/build/Release
  87. ${GLBINDING_DIR}/build-release
  88. DOC "The glbinding binary")
  89. find_file(GLBINDING_BINARY_DEBUG
  90. NAMES glbindingd.dll
  91. PATHS
  92. ${GLBINDING_DIR}/bin
  93. ${GLBINDING_DIR}/build/Debug
  94. ${GLBINDING_DIR}/build-debug
  95. DOC "The glbinding debug binary")
  96. if(NOT GLBINDING_BINARY_RELEASE STREQUAL "GLBINDING_BINARY_RELEASE-NOTFOUND")
  97. list(APPEND GLBINDING_BINARIES ${GLBINDING_BINARY_RELEASE})
  98. endif()
  99. if(NOT GLBINDING_BINARY_DEBUG STREQUAL "GLBINDING_BINARY_DEBUG-NOTFOUND")
  100. list(APPEND GLBINDING_BINARIES ${GLBINDING_BINARY_DEBUG})
  101. endif()
  102. # DEBUG
  103. # message("${LIB_NAME_UPPER}_BINARIES = ${${LIB_NAME_UPPER}_BINARIES}")
  104. endif()
  105. # DEBUG
  106. # message("GLBINDING_INCLUDE_DIRS = ${GLBINDING_INCLUDE_DIRS}")
  107. # message("GLBINDING_LIBRARIES = ${GLBINDING_LIBRARIES}")
  108. include(FindPackageHandleStandardArgs)
  109. find_package_handle_standard_args(GLBINDING DEFAULT_MSG GLBINDING_LIBRARIES GLBINDING_INCLUDE_DIRS)
  110. mark_as_advanced(GLBINDING_FOUND)