FindWwise.cmake 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. # Wwise Install Path
  9. set(LY_WWISE_INSTALL_PATH "" CACHE PATH "Path to Wwise installation.")
  10. # Wwise Version
  11. set(WWISE_VERSION)
  12. set(MINIMUM_WWISE_VERSION "2021.1.1.0")
  13. # Inspect a file in the Wwise SDK, extract the version and check it...
  14. function(is_valid_sdk sdk_path is_valid)
  15. set(${is_valid} FALSE PARENT_SCOPE)
  16. if(EXISTS ${sdk_path})
  17. set(sdk_version_file ${sdk_path}/SDK/include/AK/AkWwiseSDKVersion.h)
  18. if(EXISTS ${sdk_version_file})
  19. set(version_regex "^.*VERSION_(MAJOR|MINOR|SUBMINOR|BUILD)[ \t]+([0-9]+)")
  20. file(STRINGS ${sdk_version_file} version_strings REGEX ${version_regex})
  21. list(LENGTH version_strings num_parts)
  22. if(num_parts EQUAL 4)
  23. set(wwise_ver)
  24. foreach(version_str ${version_strings})
  25. string(REGEX REPLACE ${version_regex} "\\2" version_part ${version_str})
  26. string(JOIN "." wwise_ver ${wwise_ver} ${version_part})
  27. endforeach()
  28. if(${wwise_ver} VERSION_GREATER_EQUAL ${MINIMUM_WWISE_VERSION})
  29. set(WWISE_VERSION ${wwise_ver} PARENT_SCOPE)
  30. set(${is_valid} TRUE PARENT_SCOPE)
  31. else()
  32. message(STATUS "Minimum supported Wwise SDK version is ${MINIMUM_WWISE_VERSION}, but detected version ${wwise_ver}.")
  33. endif()
  34. endif()
  35. endif()
  36. endif()
  37. endfunction()
  38. # Paths that will be checked, in order:
  39. # - CMake cache variable
  40. # - WWISEROOT Environment Variable
  41. set(WWISE_SDK_PATHS
  42. "${LY_WWISE_INSTALL_PATH}"
  43. "$ENV{WWISEROOT}"
  44. )
  45. set(found_sdk FALSE)
  46. foreach(candidate_path ${WWISE_SDK_PATHS})
  47. is_valid_sdk(${candidate_path} found_sdk)
  48. if(found_sdk)
  49. # Update the Wwise Install Path variable internally
  50. set(LY_WWISE_INSTALL_PATH "${candidate_path}")
  51. break()
  52. endif()
  53. endforeach()
  54. if(NOT found_sdk)
  55. # If we don't find a path that appears to be a valid Wwise install, we can bail here.
  56. # No 3rdParty::Wwise target will exist, so that can be checked elsewhere.
  57. return()
  58. endif()
  59. message(STATUS "Using Wwise SDK version ${WWISE_VERSION} at ${LY_WWISE_INSTALL_PATH}")
  60. set(WWISE_COMMON_LIB_NAMES
  61. # Core AK
  62. AkMemoryMgr
  63. AkMusicEngine
  64. AkSoundEngine
  65. AkStreamMgr
  66. AkSpatialAudio
  67. # AK Effects
  68. AkCompressorFX
  69. AkDelayFX
  70. AkMatrixReverbFX
  71. AkMeterFX
  72. AkExpanderFX
  73. AkParametricEQFX
  74. AkGainFX
  75. AkPeakLimiterFX
  76. AkRoomVerbFX
  77. AkGuitarDistortionFX
  78. AkStereoDelayFX
  79. AkPitchShifterFX
  80. AkTimeStretchFX
  81. AkFlangerFX
  82. AkTremoloFX
  83. AkHarmonizerFX
  84. AkRecorderFX
  85. # AK Sources
  86. AkSilenceSource
  87. AkSineSource
  88. AkToneSource
  89. AkAudioInputSource
  90. AkSynthOneSource
  91. )
  92. set(WWISE_CODEC_LIB_NAMES
  93. # AK Codecs
  94. AkVorbisDecoder
  95. AkOpusDecoder
  96. )
  97. set(WWISE_NON_RELEASE_LIB_NAMES
  98. # For remote profiling
  99. CommunicationCentral
  100. )
  101. set(WWISE_ADDITIONAL_LIB_NAMES
  102. # Additional Libraries
  103. )
  104. set(WWISE_COMPILE_DEFINITIONS
  105. $<IF:$<CONFIG:Release>,AK_OPTIMIZED,>
  106. )
  107. # Use these to get the parent path and folder name before adding the external 3p target.
  108. get_filename_component(WWISE_INSTALL_ROOT ${LY_WWISE_INSTALL_PATH} DIRECTORY)
  109. get_filename_component(WWISE_FOLDER ${LY_WWISE_INSTALL_PATH} NAME)
  110. ly_add_external_target(
  111. NAME Wwise
  112. VERSION "${WWISE_FOLDER}"
  113. 3RDPARTY_ROOT_DIRECTORY "${WWISE_INSTALL_ROOT}"
  114. INCLUDE_DIRECTORIES SDK/include
  115. COMPILE_DEFINITIONS ${WWISE_COMPILE_DEFINITIONS}
  116. )
  117. set(Wwise_FOUND TRUE)