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.

FindThirdPartyOpenAL.cmake 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # ---------------------------------
  2. # Finds OpenAL, ALUT, OGGVORBIS
  3. # Adds library to target
  4. # Adds include path
  5. # ---------------------------------
  6. GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyOpenAL)
  7. IF(WIN32)
  8. FIND_PATH(PATH_OPENAL include/al.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES openal . NO_DEFAULT_PATH)
  9. FIND_PATH(PATH_ALUT include/AL/alut.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES freealut .)
  10. FIND_PATH(PATH_OGG include/ogg/ogg.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES libogg .)
  11. FIND_PATH(PATH_VORBIS include/vorbis/vorbisfile.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES libvorbis .)
  12. SET(BUILDTYPE_PATH_DEBUG "debug")
  13. SET(BUILDTYPE_PATH_RELEASE "release")
  14. IF(PATH_OPENAL)
  15. OV_PRINT(OV_PRINTED " Found OpenAL...")
  16. IF("${PLATFORM_TARGET}" STREQUAL "x64")
  17. SET(OPENAL_SUBDIR "Win64")
  18. ELSE()
  19. SET(OPENAL_SUBDIR "Win32")
  20. ENDIF()
  21. FIND_LIBRARY(LIB_OPENAL OpenAL32 PATHS ${PATH_OPENAL}/libs/${OPENAL_SUBDIR}/ NO_DEFAULT_PATH)
  22. IF(LIB_OPENAL)
  23. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_OPENAL}")
  24. INSTALL(DIRECTORY "${PATH_OPENAL}/libs/${OPENAL_SUBDIR}/" DESTINATION "${DIST_BINDIR}/" FILES_MATCHING PATTERN "*.dll" PATTERN "EFX*" EXCLUDE)
  25. ELSE(LIB_OPENAL)
  26. OV_PRINT(OV_PRINTED " [FAILED] lib OpenAL32")
  27. SET(OPENAL_MISSED_SOMETHING YES)
  28. ENDIF(LIB_OPENAL)
  29. ELSE(PATH_OPENAL)
  30. OV_PRINT(OV_PRINTED " FAILED to find OpenAL32")
  31. SET(OPENAL_MISSED_SOMETHING YES)
  32. ENDIF(PATH_OPENAL)
  33. IF(PATH_ALUT)
  34. FIND_LIBRARY(LIB_ALUT alut PATHS ${PATH_ALUT}/lib NO_DEFAULT_PATH)
  35. IF(LIB_ALUT)
  36. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_ALUT}")
  37. INSTALL(DIRECTORY "${PATH_ALUT}/lib/" DESTINATION "${DIST_BINDIR}/" FILES_MATCHING PATTERN "*.dll")
  38. ELSE(LIB_ALUT)
  39. OV_PRINT(OV_PRINTED " [FAILED] lib alut")
  40. SET(OPENAL_MISSED_SOMETHING YES)
  41. ENDIF(LIB_ALUT)
  42. ELSE(PATH_ALUT)
  43. OV_PRINT(OV_PRINTED " -- FAILED to find ALUT")
  44. SET(OPENAL_MISSED_SOMETHING YES)
  45. ENDIF(PATH_ALUT)
  46. IF(PATH_OGG)
  47. FIND_LIBRARY(LIB_OGG_RELEASE libogg PATHS ${PATH_OGG}/win32/lib/${BUILDTYPE_PATH_RELEASE} NO_DEFAULT_PATH)
  48. IF(LIB_OGG_RELEASE)
  49. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_OGG_RELEASE} (release)")
  50. # We only have release OpenAL, so we have to include release version for libogg, and libvorbis
  51. INSTALL(DIRECTORY "${PATH_OGG}/win32/bin/${BUILDTYPE_PATH_RELEASE}/" DESTINATION "${DIST_BINDIR}/") # CONFIGURATIONS Release)
  52. ELSE(LIB_OGG_RELEASE)
  53. OV_PRINT(OV_PRINTED " [FAILED] lib ogg (release)")
  54. SET(OPENAL_MISSED_SOMETHING YES)
  55. ENDIF(LIB_OGG_RELEASE)
  56. FIND_LIBRARY(LIB_OGG_DEBUG libogg PATHS ${PATH_OGG}/win32/lib/${BUILDTYPE_PATH_DEBUG} NO_DEFAULT_PATH)
  57. IF(LIB_OGG_DEBUG)
  58. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_OGG_DEBUG} (debug)")
  59. # INSTALL(DIRECTORY "${PATH_OGG}/win32/bin/${BUILDTYPE_PATH_DEBUG}/" DESTINATION "${DIST_BINDIR}/" CONFIGURATIONS Debug)
  60. ELSE(LIB_OGG_DEBUG)
  61. OV_PRINT(OV_PRINTED " [FAILED] lib ogg (debug)")
  62. SET(OPENAL_MISSED_SOMETHING YES)
  63. ENDIF(LIB_OGG_DEBUG)
  64. ELSE(PATH_OGG)
  65. OV_PRINT(OV_PRINTED " -- FAILED to find OGG")
  66. SET(OPENAL_MISSED_SOMETHING YES)
  67. ENDIF(PATH_OGG)
  68. IF(PATH_VORBIS)
  69. FIND_LIBRARY(LIB_VORBIS_RELEASE libvorbis PATHS ${PATH_VORBIS}/win32/lib/${BUILDTYPE_PATH_RELEASE} NO_DEFAULT_PATH)
  70. IF(LIB_VORBIS_RELEASE)
  71. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_VORBIS_RELEASE} (release)")
  72. INSTALL(FILES "${PATH_VORBIS}/win32/bin/${BUILDTYPE_PATH_RELEASE}/libvorbis.dll" DESTINATION "${DIST_BINDIR}") # CONFIGURATIONS Release)
  73. ELSE(LIB_VORBIS_RELEASE)
  74. OV_PRINT(OV_PRINTED " [FAILED] lib vorbis (release)")
  75. SET(OPENAL_MISSED_SOMETHING YES)
  76. ENDIF(LIB_VORBIS_RELEASE)
  77. FIND_LIBRARY(LIB_VORBIS_DEBUG libvorbis PATHS ${PATH_VORBIS}/win32/lib/${BUILDTYPE_PATH_DEBUG} NO_DEFAULT_PATH)
  78. IF(LIB_VORBIS_DEBUG)
  79. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_VORBIS_DEBUG} (debug)")
  80. # INSTALL(FILES "${PATH_VORBIS}/win32/bin/${BUILDTYPE_PATH_DEBUG}/libvorbis.dll" DESTINATION "${DIST_BINDIR}" CONFIGURATIONS Debug)
  81. ELSE(LIB_VORBIS_DEBUG)
  82. OV_PRINT(OV_PRINTED " [FAILED] lib vorbis (debug)")
  83. SET(OPENAL_MISSED_SOMETHING YES)
  84. ENDIF(LIB_VORBIS_DEBUG)
  85. FIND_LIBRARY(LIB_VORBISFILE_RELEASE libvorbisfile PATHS ${PATH_VORBIS}/win32/lib/${BUILDTYPE_PATH_RELEASE} NO_DEFAULT_PATH)
  86. IF(LIB_VORBISFILE_RELEASE)
  87. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_VORBISFILE_RELEASE} (release)")
  88. INSTALL(FILES "${PATH_VORBIS}/win32/bin/${BUILDTYPE_PATH_RELEASE}/libvorbisfile.dll" DESTINATION "${DIST_BINDIR}")# CONFIGURATIONS Release)
  89. ELSE(LIB_VORBISFILE_RELEASE)
  90. OV_PRINT(OV_PRINTED " [FAILED] lib vorbisfile (release)")
  91. SET(OPENAL_MISSED_SOMETHING YES)
  92. ENDIF(LIB_VORBISFILE_RELEASE)
  93. FIND_LIBRARY(LIB_VORBISFILE_DEBUG libvorbisfile PATHS ${PATH_VORBIS}/win32/lib/${BUILDTYPE_PATH_DEBUG} NO_DEFAULT_PATH)
  94. IF(LIB_VORBISFILE_DEBUG)
  95. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_VORBISFILE_DEBUG} (debug)")
  96. # INSTALL(FILES "${PATH_VORBIS}/win32/bin/${BUILDTYPE_PATH_DEBUG}/libvorbisfile.dll" DESTINATION "${DIST_BINDIR}" CONFIGURATIONS Debug)
  97. ELSE(LIB_VORBISFILE_DEBUG)
  98. OV_PRINT(OV_PRINTED " [FAILED] lib vorbisfile (debug)")
  99. SET(OPENAL_MISSED_SOMETHING YES)
  100. ENDIF(LIB_VORBISFILE_DEBUG)
  101. ELSE(PATH_VORBIS)
  102. OV_PRINT(OV_PRINTED " -- FAILED to find VORBIS")
  103. SET(OPENAL_MISSED_SOMETHING YES)
  104. ENDIF(PATH_VORBIS)
  105. IF(OPENAL_MISSED_SOMETHING)
  106. OV_PRINT(OV_PRINTED " FAILED to find everything required by OpenAL")
  107. ELSE(OPENAL_MISSED_SOMETHING)
  108. OV_PRINT(OV_PRINTED " Found OpenAL and all its library dependencies...")
  109. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_OPENAL})
  110. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_ALUT})
  111. TARGET_LINK_LIBRARIES(${PROJECT_NAME} debug ${LIB_OGG_DEBUG} optimized ${LIB_OGG_RELEASE} )
  112. TARGET_LINK_LIBRARIES(${PROJECT_NAME} debug ${LIB_VORBIS_DEBUG} optimized ${LIB_VORBIS_RELEASE} )
  113. TARGET_LINK_LIBRARIES(${PROJECT_NAME} debug ${LIB_VORBISFILE_DEBUG} optimized ${LIB_VORBISFILE_RELEASE})
  114. INCLUDE_DIRECTORIES(${PATH_OPENAL}/include ${PATH_ALUT}/include ${PATH_OGG}/include ${PATH_VORBIS}/include)
  115. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenAL)
  116. ENDIF(OPENAL_MISSED_SOMETHING)
  117. ENDIF(WIN32)
  118. IF(UNIX)
  119. INCLUDE("FindThirdPartyPkgConfig")
  120. pkg_check_modules(ALUT freealut)
  121. IF(ALUT_FOUND)
  122. OV_PRINT(OV_PRINTED " Found ALUT...")
  123. INCLUDE_DIRECTORIES(${ALUT_INCLUDE_DIRS})
  124. ADD_DEFINITIONS(${ALUT_CFLAGS})
  125. ADD_DEFINITIONS(${ALUT_CFLAGS_OTHERS})
  126. # LINK_DIRECTORIES(${ALUT_LIBRARY_DIRS})
  127. FOREACH(ALUT_LIB ${ALUT_LIBRARIES})
  128. SET(ALUT_LIB1 "ALUT_LIB1-NOTFOUND")
  129. FIND_LIBRARY(ALUT_LIB1 NAMES ${ALUT_LIB} PATHS ${ALUT_LIBRARY_DIRS} ${ALUT_LIBDIR} NO_DEFAULT_PATH)
  130. FIND_LIBRARY(ALUT_LIB1 NAMES ${ALUT_LIB})
  131. IF(ALUT_LIB1)
  132. OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${ALUT_LIB1}")
  133. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${ALUT_LIB1})
  134. ELSE(ALUT_LIB1)
  135. OV_PRINT(OV_PRINTED " [FAILED] Third party lib ${ALUT_LIB}")
  136. ENDIF(ALUT_LIB1)
  137. ENDFOREACH(ALUT_LIB)
  138. ELSE(ALUT_FOUND)
  139. OV_PRINT(OV_PRINTED " FAILED to find ALUT...")
  140. ENDIF(ALUT_FOUND)
  141. pkg_check_modules(VORBIS vorbisfile)
  142. IF(VORBIS_FOUND)
  143. OV_PRINT(OV_PRINTED " Found VORBIS...")
  144. INCLUDE_DIRECTORIES(${VORBIS_INCLUDE_DIRS})
  145. ADD_DEFINITIONS(${VORBIS_CFLAGS})
  146. ADD_DEFINITIONS(${VORBIS_CFLAGS_OTHERS})
  147. # LINK_DIRECTORIES(${VORBIS_LIBRARY_DIRS})
  148. FOREACH(VORBIS_LIB ${VORBIS_LIBRARIES})
  149. SET(VORBIS_LIB1 "VORBIS_LIB1-NOTFOUND")
  150. FIND_LIBRARY(VORBIS_LIB1 NAMES ${VORBIS_LIB} PATHS ${VORBIS_LIBRARY_DIRS} ${VORBIS_LIBDIR} NO_DEFAULT_PATH)
  151. FIND_LIBRARY(VORBIS_LIB1 NAMES ${VORBIS_LIB})
  152. IF(VORBIS_LIB1)
  153. OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${VORBIS_LIB1}")
  154. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${VORBIS_LIB1})
  155. ELSE(VORBIS_LIB1)
  156. OV_PRINT(OV_PRINTED " [FAILED] Third party lib ${VORBIS_LIB}")
  157. ENDIF(VORBIS_LIB1)
  158. ENDFOREACH(VORBIS_LIB)
  159. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyOpenAL)
  160. ELSE(VORBIS_FOUND)
  161. OV_PRINT(OV_PRINTED " FAILED to find VORBIS...")
  162. ENDIF(VORBIS_FOUND)
  163. ENDIF(UNIX)
  164. SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyOpenAL "Yes")