Open Source Tomb Raider Engine
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.

FindALUT.cmake 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # - try to find the OpenAL ALUT library
  2. #
  3. # Users may optionally supply:
  4. # ALUT_ROOT_DIR - a prefix to start searching.
  5. #
  6. # Cache Variables: (probably not for direct use in your scripts)
  7. # ALUT_INCLUDE_DIR
  8. # ALUT_LIBRARY
  9. #
  10. # Non-cache variables you might use in your CMakeLists.txt:
  11. # ALUT_FOUND
  12. # ALUT_INCLUDE_DIRS
  13. # ALUT_LIBRARIES
  14. # ALUT_WORKAROUND_INCLUDE_DIRS - add these to your include path with
  15. # include_directories(${ALUT_WORKAROUND_INCLUDE_DIRS} ${ALUT_INCLUDE_DIRS})
  16. # so you can always #include <AL/al.h> and #include <AL/alut.h> even on
  17. # Mac where the paths might differ.
  18. #
  19. # Requires these CMake modules:
  20. # FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
  21. #
  22. # Original Author:
  23. # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
  24. # http://academic.cleardefinition.com
  25. # Iowa State University HCI Graduate Program/VRAC
  26. #
  27. # Copyright Iowa State University 2009-2010.
  28. # Distributed under the Boost Software License, Version 1.0.
  29. #
  30. # Permission is hereby granted, free of charge, to any person or organization
  31. # obtaining a copy of the software and accompanying documentation covered by
  32. # this license (the "Software") to use, reproduce, display, distribute,
  33. # execute, and transmit the Software, and to prepare derivative works of the
  34. # Software, and to permit third-parties to whom the Software is furnished to
  35. # do so, all subject to the following:
  36. #
  37. # The copyright notices in the Software and this entire statement, including
  38. # the above license grant, this restriction and the following disclaimer,
  39. # must be included in all copies of the Software, in whole or in part, and
  40. # all derivative works of the Software, unless such copies or derivative
  41. # works are solely in the form of machine-executable object code generated by
  42. # a source language processor.
  43. #
  44. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46. # FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  47. # SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  48. # FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  49. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  50. # DEALINGS IN THE SOFTWARE.
  51. set(ALUT_ROOT_DIR
  52. "${ALUT_ROOT_DIR}"
  53. CACHE
  54. PATH
  55. "Path to search for ALUT library")
  56. # Share search paths with OpenAL
  57. if(NOT "$ENV{OPENALDIR}" STREQUAL "")
  58. if(NOT ALUT_ROOT_DIR)
  59. set(ALUT_ROOT_DIR "$ENV{OPENALDIR}")
  60. endif()
  61. else()
  62. if(ALUT_ROOT_DIR)
  63. set(ENV{OPENALDIR} "${ALUT_ROOT_DIR}")
  64. endif()
  65. endif()
  66. ###
  67. # Configure ALUT
  68. ###
  69. find_path(ALUT_INCLUDE_DIR
  70. NAMES
  71. alut.h
  72. HINTS
  73. "${ALUT_ROOT_DIR}"
  74. PATH_SUFFIXES
  75. AL
  76. alut
  77. OpenAL
  78. include
  79. include/alut
  80. include/freealut
  81. include/AL
  82. include/OpenAL
  83. PATHS
  84. /usr/local
  85. /opt/local
  86. /sw)
  87. mark_as_advanced(ALUT_INCLUDE_DIR)
  88. find_library(ALUT_LIBRARY
  89. NAMES
  90. alut
  91. HINTS
  92. "${ALUT_ROOT_DIR}"
  93. PATH_SUFFIXES
  94. lib
  95. lib64
  96. PATHS
  97. /usr/local
  98. /opt/local
  99. /sw)
  100. mark_as_advanced(ALUT_LIBRARY)
  101. ###
  102. # Prereq: OpenAL
  103. ###
  104. # On Mac OS X, the ALUT headers were in the OpenAL framework until 10.4.7
  105. # If we found ALUT headers elsewhere, it's probably freealut which may
  106. # define the same symbols as the library in the framework (?)
  107. # so we might want to save/restore the CMake variable that controls searching
  108. # in frameworks
  109. find_package(OpenAL QUIET)
  110. # handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
  111. # all listed variables are TRUE
  112. include(FindPackageHandleStandardArgs)
  113. find_package_handle_standard_args(ALUT
  114. DEFAULT_MSG
  115. ALUT_LIBRARY
  116. ALUT_INCLUDE_DIR
  117. OPENAL_FOUND)
  118. if(ALUT_FOUND)
  119. set(ALUT_INCLUDE_DIRS "${OPENAL_INCLUDE_DIR}" "${ALUT_INCLUDE_DIR}")
  120. set(ALUT_LIBRARIES "${OPENAL_LIBRARY}" ${ALUT_LIBRARY})
  121. if(APPLE)
  122. get_filename_component(_moddir ${CMAKE_CURRENT_LIST_FILE} PATH)
  123. if("${OPENAL_INCLUDE_DIR}" MATCHES "\\.framework$")
  124. # OpenAL is in a framework - need a workaround
  125. set(OPENAL_WORKAROUND_INCLUDE_DIR
  126. "${_moddir}/workarounds/mac-openal")
  127. list(APPEND
  128. ALUT_WORKAROUND_INCLUDE_DIRS
  129. "${OPENAL_WORKAROUND_INCLUDE_DIR}")
  130. endif()
  131. if("${ALUT_INCLUDE_DIR}" MATCHES "\\.framework$")
  132. # ALUT is in the OpenAL framework - need a workaround
  133. set(ALUT_WORKAROUND_INCLUDE_DIR
  134. "${_moddir}/workarounds/mac-alut-framework")
  135. list(APPEND
  136. ALUT_WORKAROUND_INCLUDE_DIRS
  137. "${ALUT_WORKAROUND_INCLUDE_DIR}")
  138. endif()
  139. endif()
  140. if("${ALUT_INCLUDE_DIR}" MATCHES "AL$")
  141. get_filename_component(_parent "${ALUT_INCLUDE_DIR}/.." ABSOLUTE)
  142. list(APPEND ALUT_INCLUDE_DIRS "${_parent}")
  143. endif()
  144. mark_as_advanced(ALUT_ROOT_DIR)
  145. endif()