🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

1661 lines
56 KiB

  1. # CMake build file list for OpenAL
  2. CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
  3. PROJECT(OpenAL)
  4. IF(COMMAND CMAKE_POLICY)
  5. CMAKE_POLICY(SET CMP0003 NEW)
  6. CMAKE_POLICY(SET CMP0005 NEW)
  7. IF(POLICY CMP0020)
  8. CMAKE_POLICY(SET CMP0020 NEW)
  9. ENDIF(POLICY CMP0020)
  10. IF(POLICY CMP0042)
  11. CMAKE_POLICY(SET CMP0042 NEW)
  12. ENDIF(POLICY CMP0042)
  13. IF(POLICY CMP0054)
  14. CMAKE_POLICY(SET CMP0054 NEW)
  15. ENDIF(POLICY CMP0054)
  16. IF(POLICY CMP0075)
  17. CMAKE_POLICY(SET CMP0075 NEW)
  18. ENDIF(POLICY CMP0075)
  19. ENDIF(COMMAND CMAKE_POLICY)
  20. SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
  21. INCLUDE(CheckFunctionExists)
  22. INCLUDE(CheckLibraryExists)
  23. INCLUDE(CheckSharedFunctionExists)
  24. INCLUDE(CheckIncludeFile)
  25. INCLUDE(CheckIncludeFiles)
  26. INCLUDE(CheckSymbolExists)
  27. INCLUDE(CheckCCompilerFlag)
  28. INCLUDE(CheckCXXCompilerFlag)
  29. INCLUDE(CheckCSourceCompiles)
  30. INCLUDE(CheckCXXSourceCompiles)
  31. INCLUDE(CheckTypeSize)
  32. include(CheckStructHasMember)
  33. include(CheckFileOffsetBits)
  34. include(GNUInstallDirs)
  35. SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
  36. OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
  37. OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
  38. OPTION(ALSOFT_UTILS "Build and install utility programs" ON)
  39. OPTION(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF)
  40. OPTION(ALSOFT_EXAMPLES "Build and install example programs" ON)
  41. OPTION(ALSOFT_TESTS "Build and install test programs" ON)
  42. OPTION(ALSOFT_CONFIG "Install alsoft.conf sample configuration file" ON)
  43. OPTION(ALSOFT_HRTF_DEFS "Install HRTF definition files" ON)
  44. OPTION(ALSOFT_AMBDEC_PRESETS "Install AmbDec preset files" ON)
  45. OPTION(ALSOFT_INSTALL "Install headers and libraries" ON)
  46. if(DEFINED SHARE_INSTALL_DIR)
  47. message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
  48. set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")
  49. endif()
  50. if(DEFINED LIB_SUFFIX)
  51. message(WARNING "LIB_SUFFIX is deprecated. Use the variables provided by the GNUInstallDirs module instead")
  52. endif()
  53. SET(CPP_DEFS ) # C pre-process, not C++
  54. SET(INC_PATHS )
  55. SET(C_FLAGS )
  56. SET(LINKER_FLAGS )
  57. SET(EXTRA_LIBS )
  58. IF(WIN32)
  59. SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502)
  60. OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
  61. # This option is mainly for static linking OpenAL Soft into another project
  62. # that already defines the IDs. It is up to that project to ensure all
  63. # required IDs are defined.
  64. OPTION(ALSOFT_NO_UID_DEFS "Do not define GUIDs, IIDs, CLSIDs, or PropertyKeys" OFF)
  65. IF(MINGW)
  66. OPTION(ALSOFT_BUILD_IMPORT_LIB "Build an import .lib using dlltool (requires sed)" ON)
  67. IF(NOT DLLTOOL)
  68. IF(HOST)
  69. SET(DLLTOOL "${HOST}-dlltool")
  70. ELSE()
  71. SET(DLLTOOL "dlltool")
  72. ENDIF()
  73. ENDIF()
  74. ENDIF()
  75. ENDIF()
  76. # QNX's gcc do not uses /usr/include and /usr/lib pathes by default
  77. IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
  78. SET(INC_PATHS ${INC_PATHS} /usr/include)
  79. SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
  80. ENDIF()
  81. IF(NOT LIBTYPE)
  82. SET(LIBTYPE SHARED)
  83. ENDIF()
  84. SET(LIB_MAJOR_VERSION "1")
  85. SET(LIB_MINOR_VERSION "19")
  86. SET(LIB_REVISION "1")
  87. SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
  88. SET(EXPORT_DECL "")
  89. SET(ALIGN_DECL "")
  90. CHECK_TYPE_SIZE("long" SIZEOF_LONG)
  91. CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
  92. CHECK_C_COMPILER_FLAG(-std=c11 HAVE_STD_C11)
  93. IF(HAVE_STD_C11)
  94. SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
  95. ELSE()
  96. CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
  97. IF(HAVE_STD_C99)
  98. SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
  99. ENDIF()
  100. ENDIF()
  101. CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD_CXX11)
  102. IF(HAVE_STD_CXX11)
  103. SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
  104. ENDIF()
  105. if(NOT WIN32)
  106. # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions
  107. CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT)
  108. IF(NOT HAVE_POSIX_MEMALIGN_DEFAULT)
  109. SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
  110. SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600")
  111. CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_POSIX)
  112. IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
  113. SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
  114. ELSE()
  115. SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
  116. ENDIF()
  117. ENDIF()
  118. UNSET(OLD_REQUIRED_FLAGS)
  119. ENDIF()
  120. # Set defines for large file support. Don't set this for Android targets. See:
  121. # https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
  122. IF(NOT ANDROID)
  123. CHECK_FILE_OFFSET_BITS()
  124. IF(_FILE_OFFSET_BITS)
  125. SET(CPP_DEFS ${CPP_DEFS} "_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
  126. SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
  127. ENDIF()
  128. SET(CPP_DEFS ${CPP_DEFS} _LARGEFILE_SOURCE _LARGE_FILES)
  129. SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
  130. ENDIF()
  131. # C99 has restrict, but C++ does not, so we can only utilize __restrict.
  132. SET(RESTRICT_DECL )
  133. CHECK_C_SOURCE_COMPILES("int *__restrict foo;
  134. int main() {return 0;}" HAVE___RESTRICT)
  135. IF(HAVE___RESTRICT)
  136. # SET(RESTRICT_DECL "__restrict")
  137. ENDIF()
  138. # Some systems may need libatomic for C11 atomic functions to work
  139. SET(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  140. SET(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES} atomic)
  141. CHECK_C_SOURCE_COMPILES("#include <stdatomic.h>
  142. int _Atomic foo = ATOMIC_VAR_INIT(0);
  143. int main()
  144. {
  145. return atomic_fetch_add(&foo, 2);
  146. }"
  147. HAVE_LIBATOMIC)
  148. IF(NOT HAVE_LIBATOMIC)
  149. SET(CMAKE_REQUIRED_LIBRARIES "${OLD_REQUIRED_LIBRARIES}")
  150. ELSE()
  151. SET(EXTRA_LIBS atomic ${EXTRA_LIBS})
  152. ENDIF()
  153. UNSET(OLD_REQUIRED_LIBRARIES)
  154. # Include liblog for Android logging
  155. CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG)
  156. IF(HAVE_LIBLOG)
  157. SET(EXTRA_LIBS log ${EXTRA_LIBS})
  158. SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log)
  159. ENDIF()
  160. IF(NOT CMAKE_BUILD_TYPE)
  161. SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  162. "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
  163. FORCE)
  164. ENDIF()
  165. IF(NOT CMAKE_DEBUG_POSTFIX)
  166. SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
  167. "Library postfix for debug builds. Normally left blank."
  168. FORCE)
  169. ENDIF()
  170. IF(MSVC)
  171. SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE NOMINMAX)
  172. SET(C_FLAGS ${C_FLAGS} /wd4065 /wd4098 /wd4200)
  173. IF(NOT DXSDK_DIR)
  174. STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
  175. ELSE()
  176. STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
  177. ENDIF()
  178. IF(DXSDK_DIR)
  179. MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
  180. ENDIF()
  181. OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
  182. IF(FORCE_STATIC_VCRT)
  183. FOREACH(flag_var
  184. CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
  185. CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
  186. IF(${flag_var} MATCHES "/MD")
  187. STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
  188. ENDIF()
  189. ENDFOREACH(flag_var)
  190. ENDIF()
  191. ELSE()
  192. SET(C_FLAGS ${C_FLAGS} -Winline -Wall)
  193. CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
  194. IF(HAVE_W_EXTRA)
  195. SET(C_FLAGS ${C_FLAGS} -Wextra)
  196. ENDIF()
  197. IF(ALSOFT_WERROR)
  198. SET(C_FLAGS ${C_FLAGS} -Werror)
  199. ENDIF()
  200. # We want RelWithDebInfo to actually include debug stuff (define _DEBUG
  201. # instead of NDEBUG)
  202. FOREACH(flag_var CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
  203. IF(${flag_var} MATCHES "-DNDEBUG")
  204. STRING(REGEX REPLACE "-DNDEBUG" "-D_DEBUG" ${flag_var} "${${flag_var}}")
  205. ENDIF()
  206. ENDFOREACH()
  207. CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO)
  208. IF(HAVE_FNO_MATH_ERRNO)
  209. SET(C_FLAGS ${C_FLAGS} -fno-math-errno)
  210. ENDIF()
  211. CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
  212. int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
  213. option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
  214. if(ALSOFT_STATIC_LIBGCC)
  215. set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  216. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
  217. check_c_source_compiles(
  218. "#include <stdlib.h>
  219. int main()
  220. {
  221. return 0;
  222. }"
  223. HAVE_STATIC_LIBGCC_SWITCH
  224. )
  225. set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
  226. unset(OLD_REQUIRED_LIBRARIES)
  227. if(NOT HAVE_STATIC_LIBGCC_SWITCH)
  228. message(FATAL_ERROR "Cannot static link libgcc")
  229. endif()
  230. set(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
  231. endif()
  232. option(ALSOFT_STATIC_STDCXX "Static link libstdc++" OFF)
  233. if(ALSOFT_STATIC_STDCXX)
  234. set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  235. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
  236. check_cxx_source_compiles(
  237. "#include <cstdlib>
  238. int main()
  239. {
  240. return 0;
  241. }"
  242. HAVE_STATIC_LIBSTDCXX_SWITCH
  243. )
  244. set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
  245. unset(OLD_REQUIRED_LIBRARIES)
  246. if(NOT HAVE_STATIC_LIBSTDCXX_SWITCH)
  247. message(FATAL_ERROR "Cannot static link libstdc++")
  248. endif()
  249. set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lstdc++,--pop-state")
  250. endif()
  251. if(WIN32)
  252. option(ALSOFT_STATIC_WINPTHREAD "Static link libwinpthread" OFF)
  253. if(ALSOFT_STATIC_WINPTHREAD)
  254. set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  255. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
  256. check_cxx_source_compiles(
  257. "#include <cstdlib>
  258. int main()
  259. {
  260. return 0;
  261. }"
  262. HAVE_STATIC_LIBWINPTHREAD_SWITCH
  263. )
  264. set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
  265. unset(OLD_REQUIRED_LIBRARIES)
  266. if(NOT HAVE_STATIC_LIBWINPTHREAD_SWITCH)
  267. message(FATAL_ERROR "Cannot static link libwinpthread")
  268. endif()
  269. set(LINKER_FLAGS ${LINKER_FLAGS} "-Wl,--push-state,-Bstatic,-lwinpthread,--pop-state")
  270. endif()
  271. endif()
  272. ENDIF()
  273. # Set visibility/export options if available
  274. IF(WIN32)
  275. SET(EXPORT_DECL "__declspec(dllexport)")
  276. IF(NOT MINGW)
  277. SET(ALIGN_DECL "__declspec(align(x))")
  278. ELSE()
  279. SET(ALIGN_DECL "__declspec(aligned(x))")
  280. ENDIF()
  281. ELSE()
  282. SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
  283. # Yes GCC, really don't accept visibility modes you don't support
  284. SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
  285. CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
  286. int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
  287. IF(HAVE_GCC_PROTECTED_VISIBILITY)
  288. SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
  289. ELSE()
  290. CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
  291. int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
  292. IF(HAVE_GCC_DEFAULT_VISIBILITY)
  293. SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
  294. ENDIF()
  295. ENDIF()
  296. IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
  297. CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
  298. IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
  299. SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden)
  300. ENDIF()
  301. ENDIF()
  302. CHECK_C_SOURCE_COMPILES("int foo __attribute__((aligned(16)));
  303. int main() {return 0;}" HAVE_ATTRIBUTE_ALIGNED)
  304. IF(HAVE_ATTRIBUTE_ALIGNED)
  305. SET(ALIGN_DECL "__attribute__((aligned(x)))")
  306. ENDIF()
  307. SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
  308. ENDIF()
  309. SET(SSE2_SWITCH "")
  310. SET(SSE3_SWITCH "")
  311. SET(SSE4_1_SWITCH "")
  312. SET(FPU_NEON_SWITCH "")
  313. CHECK_C_COMPILER_FLAG(-msse2 HAVE_MSSE2_SWITCH)
  314. IF(HAVE_MSSE2_SWITCH)
  315. SET(SSE2_SWITCH "-msse2")
  316. ENDIF()
  317. CHECK_C_COMPILER_FLAG(-msse3 HAVE_MSSE3_SWITCH)
  318. IF(HAVE_MSSE3_SWITCH)
  319. SET(SSE3_SWITCH "-msse3")
  320. ENDIF()
  321. CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_MSSE4_1_SWITCH)
  322. IF(HAVE_MSSE4_1_SWITCH)
  323. SET(SSE4_1_SWITCH "-msse4.1")
  324. ENDIF()
  325. CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_MFPU_NEON_SWITCH)
  326. IF(HAVE_MFPU_NEON_SWITCH)
  327. SET(FPU_NEON_SWITCH "-mfpu=neon")
  328. ENDIF()
  329. CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
  330. CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
  331. CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
  332. CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
  333. CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
  334. SET(SSE_FLAGS )
  335. SET(FPMATH_SET "0")
  336. IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
  337. IF(SSE2_SWITCH OR MSVC)
  338. OPTION(ALSOFT_ENABLE_SSE2_CODEGEN "Enable SSE2 code generation instead of x87 for 32-bit targets." TRUE)
  339. ENDIF()
  340. IF(ALSOFT_ENABLE_SSE2_CODEGEN)
  341. IF(SSE2_SWITCH)
  342. CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
  343. IF(HAVE_MFPMATH_SSE_2)
  344. SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
  345. SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
  346. SET(FPMATH_SET 2)
  347. ENDIF()
  348. ELSEIF(MSVC)
  349. CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2)
  350. IF(HAVE_ARCH_SSE2)
  351. SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
  352. SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
  353. SET(FPMATH_SET 2)
  354. ENDIF()
  355. ENDIF()
  356. ENDIF()
  357. ENDIF()
  358. IF(HAVE_EMMINTRIN_H)
  359. SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
  360. FOREACH(flag_var ${SSE_FLAGS})
  361. SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
  362. ENDFOREACH()
  363. CHECK_C_SOURCE_COMPILES("#include <emmintrin.h>
  364. int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
  365. SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
  366. ENDIF()
  367. CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
  368. int main() {return 0;}" HAVE_GCC_FORMAT)
  369. CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
  370. CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
  371. CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
  372. CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
  373. CHECK_INCLUDE_FILE(intrin.h HAVE_INTRIN_H)
  374. CHECK_INCLUDE_FILE(sys/sysconf.h HAVE_SYS_SYSCONF_H)
  375. CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
  376. CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
  377. CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
  378. CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
  379. IF(NOT HAVE_GUIDDEF_H)
  380. CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H)
  381. ENDIF()
  382. # Some systems need libm for some of the following math functions to work
  383. SET(MATH_LIB )
  384. CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
  385. IF(HAVE_LIBM)
  386. SET(MATH_LIB ${MATH_LIB} m)
  387. SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
  388. ENDIF()
  389. # Check for the dlopen API (for dynamicly loading backend libs)
  390. IF(ALSOFT_DLOPEN)
  391. CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
  392. IF(HAVE_LIBDL)
  393. SET(EXTRA_LIBS dl ${EXTRA_LIBS})
  394. SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
  395. ENDIF()
  396. CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
  397. ENDIF()
  398. # Check for a cpuid intrinsic
  399. IF(HAVE_CPUID_H)
  400. CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
  401. int main()
  402. {
  403. unsigned int eax, ebx, ecx, edx;
  404. return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
  405. }" HAVE_GCC_GET_CPUID)
  406. ENDIF()
  407. IF(HAVE_INTRIN_H)
  408. CHECK_C_SOURCE_COMPILES("#include <intrin.h>
  409. int main()
  410. {
  411. int regs[4];
  412. __cpuid(regs, 0);
  413. return regs[0];
  414. }" HAVE_CPUID_INTRINSIC)
  415. CHECK_C_SOURCE_COMPILES("#include <intrin.h>
  416. int main()
  417. {
  418. unsigned long idx = 0;
  419. _BitScanForward64(&idx, 1);
  420. return idx;
  421. }" HAVE_BITSCANFORWARD64_INTRINSIC)
  422. CHECK_C_SOURCE_COMPILES("#include <intrin.h>
  423. int main()
  424. {
  425. unsigned long idx = 0;
  426. _BitScanForward(&idx, 1);
  427. return idx;
  428. }" HAVE_BITSCANFORWARD_INTRINSIC)
  429. ENDIF()
  430. CHECK_SYMBOL_EXISTS(sysconf unistd.h HAVE_SYSCONF)
  431. CHECK_SYMBOL_EXISTS(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
  432. CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
  433. CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
  434. CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH)
  435. CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
  436. CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
  437. IF(NOT HAVE_STRCASECMP)
  438. CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
  439. IF(NOT HAVE__STRICMP)
  440. MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
  441. ENDIF()
  442. SET(CPP_DEFS ${CPP_DEFS} strcasecmp=_stricmp)
  443. ENDIF()
  444. CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
  445. IF(NOT HAVE_STRNCASECMP)
  446. CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
  447. IF(NOT HAVE__STRNICMP)
  448. MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
  449. ENDIF()
  450. SET(CPP_DEFS ${CPP_DEFS} strncasecmp=_strnicmp)
  451. ENDIF()
  452. # Check if we have Windows headers
  453. SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
  454. SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
  455. CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
  456. SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
  457. UNSET(OLD_REQUIRED_DEFINITIONS)
  458. IF(NOT HAVE_WINDOWS_H)
  459. CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
  460. IF(NOT HAVE_GETTIMEOFDAY)
  461. MESSAGE(FATAL_ERROR "No timing function found!")
  462. ENDIF()
  463. CHECK_SYMBOL_EXISTS(nanosleep time.h HAVE_NANOSLEEP)
  464. IF(NOT HAVE_NANOSLEEP)
  465. MESSAGE(FATAL_ERROR "No sleep function found!")
  466. ENDIF()
  467. # We need pthreads outside of Windows
  468. CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
  469. IF(NOT HAVE_PTHREAD_H)
  470. MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
  471. ENDIF()
  472. # Some systems need pthread_np.h to get recursive mutexes
  473. CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
  474. CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
  475. IF(HAVE_PTHREAD)
  476. SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
  477. SET(C_FLAGS ${C_FLAGS} -pthread)
  478. SET(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
  479. ENDIF()
  480. CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
  481. IF(HAVE_LIBPTHREAD)
  482. SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
  483. ENDIF()
  484. CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
  485. IF(HAVE_PTHREAD_NP_H)
  486. CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SETNAME_NP)
  487. IF(NOT HAVE_PTHREAD_SETNAME_NP)
  488. CHECK_SYMBOL_EXISTS(pthread_set_name_np "pthread.h;pthread_np.h" HAVE_PTHREAD_SET_NAME_NP)
  489. ELSE()
  490. CHECK_C_SOURCE_COMPILES("
  491. #include <pthread.h>
  492. #include <pthread_np.h>
  493. int main()
  494. {
  495. pthread_setname_np(\"testname\");
  496. return 0;
  497. }"
  498. PTHREAD_SETNAME_NP_ONE_PARAM
  499. )
  500. CHECK_C_SOURCE_COMPILES("
  501. #include <pthread.h>
  502. #include <pthread_np.h>
  503. int main()
  504. {
  505. pthread_setname_np(pthread_self(), \"%s\", \"testname\");
  506. return 0;
  507. }"
  508. PTHREAD_SETNAME_NP_THREE_PARAMS
  509. )
  510. ENDIF()
  511. ELSE()
  512. CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
  513. IF(NOT HAVE_PTHREAD_SETNAME_NP)
  514. CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
  515. ELSE()
  516. CHECK_C_SOURCE_COMPILES("
  517. #include <pthread.h>
  518. int main()
  519. {
  520. pthread_setname_np(\"testname\");
  521. return 0;
  522. }"
  523. PTHREAD_SETNAME_NP_ONE_PARAM
  524. )
  525. CHECK_C_SOURCE_COMPILES("
  526. #include <pthread.h>
  527. int main()
  528. {
  529. pthread_setname_np(pthread_self(), \"%s\", \"testname\");
  530. return 0;
  531. }"
  532. PTHREAD_SETNAME_NP_THREE_PARAMS
  533. )
  534. ENDIF()
  535. ENDIF()
  536. CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
  537. IF(HAVE_LIBRT)
  538. SET(EXTRA_LIBS rt ${EXTRA_LIBS})
  539. ENDIF()
  540. ENDIF()
  541. CHECK_SYMBOL_EXISTS(getopt unistd.h HAVE_GETOPT)
  542. # Check for a 64-bit type
  543. CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
  544. IF(NOT HAVE_STDINT_H)
  545. IF(NOT SIZEOF_LONG MATCHES "8")
  546. IF(NOT SIZEOF_LONG_LONG MATCHES "8")
  547. MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
  548. ENDIF()
  549. ENDIF()
  550. ENDIF()
  551. # Common sources used by both the OpenAL implementation library and potentially
  552. # the OpenAL router.
  553. SET(COMMON_OBJS
  554. common/alcomplex.cpp
  555. common/alcomplex.h
  556. common/alexcpt.cpp
  557. common/alexcpt.h
  558. common/almalloc.cpp
  559. common/almalloc.h
  560. common/alnumeric.h
  561. common/alspan.h
  562. common/atomic.h
  563. common/math_defs.h
  564. common/opthelpers.h
  565. common/threads.cpp
  566. common/threads.h
  567. common/vecmat.h
  568. )
  569. SET(OPENAL_OBJS
  570. OpenAL32/Include/alMain.h
  571. OpenAL32/Include/alu.h
  572. OpenAL32/Include/alAuxEffectSlot.h
  573. OpenAL32/alAuxEffectSlot.cpp
  574. OpenAL32/Include/alBuffer.h
  575. OpenAL32/alBuffer.cpp
  576. OpenAL32/Include/alEffect.h
  577. OpenAL32/alEffect.cpp
  578. OpenAL32/Include/alError.h
  579. OpenAL32/alError.cpp
  580. OpenAL32/alExtension.cpp
  581. OpenAL32/Include/alFilter.h
  582. OpenAL32/alFilter.cpp
  583. OpenAL32/Include/alListener.h
  584. OpenAL32/alListener.cpp
  585. OpenAL32/Include/alSource.h
  586. OpenAL32/alSource.cpp
  587. OpenAL32/alState.cpp
  588. OpenAL32/event.cpp
  589. OpenAL32/Include/sample_cvt.h
  590. OpenAL32/sample_cvt.cpp
  591. )
  592. SET(ALC_OBJS
  593. Alc/alc.cpp
  594. Alc/alu.cpp
  595. Alc/alconfig.cpp
  596. Alc/alconfig.h
  597. Alc/alcontext.h
  598. Alc/ambidefs.h
  599. Alc/bs2b.cpp
  600. Alc/bs2b.h
  601. Alc/converter.cpp
  602. Alc/converter.h
  603. Alc/inprogext.h
  604. Alc/mastering.cpp
  605. Alc/mastering.h
  606. Alc/ringbuffer.cpp
  607. Alc/ringbuffer.h
  608. Alc/effects/base.h
  609. Alc/effects/autowah.cpp
  610. Alc/effects/chorus.cpp
  611. Alc/effects/compressor.cpp
  612. Alc/effects/dedicated.cpp
  613. Alc/effects/distortion.cpp
  614. Alc/effects/echo.cpp
  615. Alc/effects/equalizer.cpp
  616. Alc/effects/fshifter.cpp
  617. Alc/effects/modulator.cpp
  618. Alc/effects/null.cpp
  619. Alc/effects/pshifter.cpp
  620. Alc/effects/reverb.cpp
  621. Alc/filters/biquad.h
  622. Alc/filters/biquad.cpp
  623. Alc/filters/nfc.cpp
  624. Alc/filters/nfc.h
  625. Alc/filters/splitter.cpp
  626. Alc/filters/splitter.h
  627. Alc/helpers.cpp
  628. Alc/compat.h
  629. Alc/cpu_caps.h
  630. Alc/fpu_modes.h
  631. Alc/logging.h
  632. Alc/vector.h
  633. Alc/hrtf.cpp
  634. Alc/hrtf.h
  635. Alc/uhjfilter.cpp
  636. Alc/uhjfilter.h
  637. Alc/ambdec.cpp
  638. Alc/ambdec.h
  639. Alc/bformatdec.cpp
  640. Alc/bformatdec.h
  641. Alc/panning.cpp
  642. Alc/mixvoice.cpp
  643. Alc/mixer/defs.h
  644. Alc/mixer/hrtfbase.h
  645. Alc/mixer/mixer_c.cpp
  646. )
  647. SET(CPU_EXTS "Default")
  648. SET(HAVE_SSE 0)
  649. SET(HAVE_SSE2 0)
  650. SET(HAVE_SSE3 0)
  651. SET(HAVE_SSE4_1 0)
  652. SET(HAVE_NEON 0)
  653. # Check for SSE+SSE2 support
  654. OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
  655. OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)
  656. IF(HAVE_XMMINTRIN_H AND HAVE_EMMINTRIN_H)
  657. OPTION(ALSOFT_CPUEXT_SSE "Enable SSE support" ON)
  658. OPTION(ALSOFT_CPUEXT_SSE2 "Enable SSE2 support" ON)
  659. IF(ALSOFT_CPUEXT_SSE AND ALSOFT_CPUEXT_SSE2)
  660. SET(HAVE_SSE 1)
  661. SET(HAVE_SSE2 1)
  662. SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse.cpp Alc/mixer/mixer_sse2.cpp)
  663. IF(SSE2_SWITCH)
  664. SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse.cpp Alc/mixer/mixer_sse2.cpp
  665. PROPERTIES COMPILE_FLAGS "${SSE2_SWITCH}")
  666. ENDIF()
  667. SET(CPU_EXTS "${CPU_EXTS}, SSE, SSE2")
  668. ENDIF()
  669. ENDIF()
  670. IF(ALSOFT_REQUIRE_SSE AND NOT HAVE_SSE)
  671. MESSAGE(FATAL_ERROR "Failed to enabled required SSE CPU extensions")
  672. ENDIF()
  673. IF(ALSOFT_REQUIRE_SSE2 AND NOT HAVE_SSE2)
  674. MESSAGE(FATAL_ERROR "Failed to enable required SSE2 CPU extensions")
  675. ENDIF()
  676. OPTION(ALSOFT_REQUIRE_SSE3 "Require SSE3 support" OFF)
  677. IF(HAVE_EMMINTRIN_H)
  678. OPTION(ALSOFT_CPUEXT_SSE3 "Enable SSE3 support" ON)
  679. IF(HAVE_SSE2 AND ALSOFT_CPUEXT_SSE3)
  680. SET(HAVE_SSE3 1)
  681. SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse3.cpp)
  682. IF(SSE2_SWITCH)
  683. SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse3.cpp PROPERTIES
  684. COMPILE_FLAGS "${SSE3_SWITCH}")
  685. ENDIF()
  686. SET(CPU_EXTS "${CPU_EXTS}, SSE3")
  687. ENDIF()
  688. ENDIF()
  689. IF(ALSOFT_REQUIRE_SSE3 AND NOT HAVE_SSE3)
  690. MESSAGE(FATAL_ERROR "Failed to enable required SSE3 CPU extensions")
  691. ENDIF()
  692. OPTION(ALSOFT_REQUIRE_SSE4_1 "Require SSE4.1 support" OFF)
  693. IF(HAVE_SMMINTRIN_H)
  694. OPTION(ALSOFT_CPUEXT_SSE4_1 "Enable SSE4.1 support" ON)
  695. IF(HAVE_SSE3 AND ALSOFT_CPUEXT_SSE4_1)
  696. SET(HAVE_SSE4_1 1)
  697. SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_sse41.cpp)
  698. IF(SSE4_1_SWITCH)
  699. SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_sse41.cpp PROPERTIES
  700. COMPILE_FLAGS "${SSE4_1_SWITCH}")
  701. ENDIF()
  702. SET(CPU_EXTS "${CPU_EXTS}, SSE4.1")
  703. ENDIF()
  704. ENDIF()
  705. IF(ALSOFT_REQUIRE_SSE4_1 AND NOT HAVE_SSE4_1)
  706. MESSAGE(FATAL_ERROR "Failed to enable required SSE4.1 CPU extensions")
  707. ENDIF()
  708. # Check for ARM Neon support
  709. OPTION(ALSOFT_REQUIRE_NEON "Require ARM Neon support" OFF)
  710. IF(HAVE_ARM_NEON_H)
  711. OPTION(ALSOFT_CPUEXT_NEON "Enable ARM Neon support" ON)
  712. IF(ALSOFT_CPUEXT_NEON)
  713. SET(HAVE_NEON 1)
  714. SET(ALC_OBJS ${ALC_OBJS} Alc/mixer/mixer_neon.cpp)
  715. IF(FPU_NEON_SWITCH)
  716. SET_SOURCE_FILES_PROPERTIES(Alc/mixer/mixer_neon.cpp PROPERTIES
  717. COMPILE_FLAGS "${FPU_NEON_SWITCH}")
  718. ENDIF()
  719. SET(CPU_EXTS "${CPU_EXTS}, Neon")
  720. ENDIF()
  721. ENDIF()
  722. IF(ALSOFT_REQUIRE_NEON AND NOT HAVE_NEON)
  723. MESSAGE(FATAL_ERROR "Failed to enabled required ARM Neon CPU extensions")
  724. ENDIF()
  725. SET(HAVE_ALSA 0)
  726. SET(HAVE_OSS 0)
  727. SET(HAVE_SOLARIS 0)
  728. SET(HAVE_SNDIO 0)
  729. SET(HAVE_QSA 0)
  730. SET(HAVE_DSOUND 0)
  731. SET(HAVE_WASAPI 0)
  732. SET(HAVE_WINMM 0)
  733. SET(HAVE_PORTAUDIO 0)
  734. SET(HAVE_PULSEAUDIO 0)
  735. SET(HAVE_COREAUDIO 0)
  736. SET(HAVE_OPENSL 0)
  737. SET(HAVE_WAVE 0)
  738. SET(HAVE_SDL2 0)
  739. IF(WIN32 OR HAVE_DLFCN_H)
  740. SET(IS_LINKED "")
  741. MACRO(ADD_BACKEND_LIBS _LIBS)
  742. ENDMACRO()
  743. ELSE()
  744. SET(IS_LINKED " (linked)")
  745. MACRO(ADD_BACKEND_LIBS _LIBS)
  746. SET(EXTRA_LIBS ${_LIBS} ${EXTRA_LIBS})
  747. ENDMACRO()
  748. ENDIF()
  749. SET(BACKENDS "")
  750. SET(ALC_OBJS ${ALC_OBJS}
  751. Alc/backends/base.cpp
  752. Alc/backends/base.h
  753. # Default backends, always available
  754. Alc/backends/loopback.cpp
  755. Alc/backends/loopback.h
  756. Alc/backends/null.cpp
  757. Alc/backends/null.h
  758. )
  759. # Check ALSA backend
  760. OPTION(ALSOFT_REQUIRE_ALSA "Require ALSA backend" OFF)
  761. FIND_PACKAGE(ALSA)
  762. IF(ALSA_FOUND)
  763. OPTION(ALSOFT_BACKEND_ALSA "Enable ALSA backend" ON)
  764. IF(ALSOFT_BACKEND_ALSA)
  765. SET(HAVE_ALSA 1)
  766. SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
  767. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.cpp Alc/backends/alsa.h)
  768. ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
  769. SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
  770. ENDIF()
  771. ENDIF()
  772. IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
  773. MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend")
  774. ENDIF()
  775. # Check OSS backend
  776. OPTION(ALSOFT_REQUIRE_OSS "Require OSS backend" OFF)
  777. FIND_PACKAGE(OSS)
  778. IF(OSS_FOUND)
  779. OPTION(ALSOFT_BACKEND_OSS "Enable OSS backend" ON)
  780. IF(ALSOFT_BACKEND_OSS)
  781. SET(HAVE_OSS 1)
  782. SET(BACKENDS "${BACKENDS} OSS,")
  783. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.cpp Alc/backends/oss.h)
  784. IF(OSS_LIBRARIES)
  785. SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
  786. ENDIF()
  787. SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
  788. ENDIF()
  789. ENDIF()
  790. IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
  791. MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend")
  792. ENDIF()
  793. # Check Solaris backend
  794. OPTION(ALSOFT_REQUIRE_SOLARIS "Require Solaris backend" OFF)
  795. FIND_PACKAGE(AudioIO)
  796. IF(AUDIOIO_FOUND)
  797. OPTION(ALSOFT_BACKEND_SOLARIS "Enable Solaris backend" ON)
  798. IF(ALSOFT_BACKEND_SOLARIS)
  799. SET(HAVE_SOLARIS 1)
  800. SET(BACKENDS "${BACKENDS} Solaris,")
  801. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.cpp Alc/backends/solaris.h)
  802. SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
  803. ENDIF()
  804. ENDIF()
  805. IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
  806. MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend")
  807. ENDIF()
  808. # Check SndIO backend
  809. OPTION(ALSOFT_REQUIRE_SNDIO "Require SndIO backend" OFF)
  810. FIND_PACKAGE(SoundIO)
  811. IF(SOUNDIO_FOUND)
  812. OPTION(ALSOFT_BACKEND_SNDIO "Enable SndIO backend" ON)
  813. IF(ALSOFT_BACKEND_SNDIO)
  814. SET(HAVE_SNDIO 1)
  815. SET(BACKENDS "${BACKENDS} SndIO (linked),")
  816. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp Alc/backends/sndio.h)
  817. SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
  818. SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
  819. ENDIF()
  820. ENDIF()
  821. IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
  822. MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend")
  823. ENDIF()
  824. # Check QSA backend
  825. OPTION(ALSOFT_REQUIRE_QSA "Require QSA backend" OFF)
  826. FIND_PACKAGE(QSA)
  827. IF(QSA_FOUND)
  828. OPTION(ALSOFT_BACKEND_QSA "Enable QSA backend" ON)
  829. IF(ALSOFT_BACKEND_QSA)
  830. SET(HAVE_QSA 1)
  831. SET(BACKENDS "${BACKENDS} QSA (linked),")
  832. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.cpp Alc/backends/qsa.h)
  833. SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
  834. SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS})
  835. ENDIF()
  836. ENDIF()
  837. IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
  838. MESSAGE(FATAL_ERROR "Failed to enabled required QSA backend")
  839. ENDIF()
  840. # Check Windows-only backends
  841. OPTION(ALSOFT_REQUIRE_WINMM "Require Windows Multimedia backend" OFF)
  842. OPTION(ALSOFT_REQUIRE_DSOUND "Require DirectSound backend" OFF)
  843. OPTION(ALSOFT_REQUIRE_WASAPI "Require WASAPI backend" OFF)
  844. IF(HAVE_WINDOWS_H)
  845. SET(OLD_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
  846. SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0502)
  847. # Check MMSystem backend
  848. CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
  849. IF(HAVE_MMSYSTEM_H)
  850. CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
  851. IF(HAVE_LIBWINMM)
  852. OPTION(ALSOFT_BACKEND_WINMM "Enable Windows Multimedia backend" ON)
  853. IF(ALSOFT_BACKEND_WINMM)
  854. SET(HAVE_WINMM 1)
  855. SET(BACKENDS "${BACKENDS} WinMM,")
  856. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.cpp Alc/backends/winmm.h)
  857. SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
  858. ENDIF()
  859. ENDIF()
  860. ENDIF()
  861. # Check DSound backend
  862. FIND_PACKAGE(DSound)
  863. IF(DSOUND_FOUND)
  864. OPTION(ALSOFT_BACKEND_DSOUND "Enable DirectSound backend" ON)
  865. IF(ALSOFT_BACKEND_DSOUND)
  866. SET(HAVE_DSOUND 1)
  867. SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
  868. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.cpp Alc/backends/dsound.h)
  869. ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
  870. SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS})
  871. ENDIF()
  872. ENDIF()
  873. # Check for WASAPI backend
  874. CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
  875. IF(HAVE_MMDEVICEAPI_H)
  876. OPTION(ALSOFT_BACKEND_WASAPI "Enable WASAPI backend" ON)
  877. IF(ALSOFT_BACKEND_WASAPI)
  878. SET(HAVE_WASAPI 1)
  879. SET(BACKENDS "${BACKENDS} WASAPI,")
  880. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wasapi.cpp Alc/backends/wasapi.h)
  881. ENDIF()
  882. ENDIF()
  883. SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_REQUIRED_DEFINITIONS})
  884. UNSET(OLD_REQUIRED_DEFINITIONS)
  885. ENDIF()
  886. IF(ALSOFT_REQUIRE_WINMM AND NOT HAVE_WINMM)
  887. MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend")
  888. ENDIF()
  889. IF(ALSOFT_REQUIRE_DSOUND AND NOT HAVE_DSOUND)
  890. MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend")
  891. ENDIF()
  892. IF(ALSOFT_REQUIRE_WASAPI AND NOT HAVE_WASAPI)
  893. MESSAGE(FATAL_ERROR "Failed to enabled required WASAPI backend")
  894. ENDIF()
  895. # Check PortAudio backend
  896. OPTION(ALSOFT_REQUIRE_PORTAUDIO "Require PortAudio backend" OFF)
  897. FIND_PACKAGE(PortAudio)
  898. IF(PORTAUDIO_FOUND)
  899. OPTION(ALSOFT_BACKEND_PORTAUDIO "Enable PortAudio backend" ON)
  900. IF(ALSOFT_BACKEND_PORTAUDIO)
  901. SET(HAVE_PORTAUDIO 1)
  902. SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
  903. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.cpp Alc/backends/portaudio.h)
  904. ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
  905. SET(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
  906. ENDIF()
  907. ENDIF()
  908. IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
  909. MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend")
  910. ENDIF()
  911. # Check PulseAudio backend
  912. OPTION(ALSOFT_REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF)
  913. FIND_PACKAGE(PulseAudio)
  914. IF(PULSEAUDIO_FOUND)
  915. OPTION(ALSOFT_BACKEND_PULSEAUDIO "Enable PulseAudio backend" ON)
  916. IF(ALSOFT_BACKEND_PULSEAUDIO)
  917. SET(HAVE_PULSEAUDIO 1)
  918. SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
  919. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.cpp Alc/backends/pulseaudio.h)
  920. ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
  921. SET(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS})
  922. ENDIF()
  923. ENDIF()
  924. IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
  925. MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend")
  926. ENDIF()
  927. # Check JACK backend
  928. OPTION(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF)
  929. FIND_PACKAGE(JACK)
  930. IF(JACK_FOUND)
  931. OPTION(ALSOFT_BACKEND_JACK "Enable JACK backend" ON)
  932. IF(ALSOFT_BACKEND_JACK)
  933. SET(HAVE_JACK 1)
  934. SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
  935. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.cpp Alc/backends/jack.h)
  936. ADD_BACKEND_LIBS(${JACK_LIBRARIES})
  937. SET(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
  938. ENDIF()
  939. ENDIF()
  940. IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
  941. MESSAGE(FATAL_ERROR "Failed to enabled required JACK backend")
  942. ENDIF()
  943. # Check CoreAudio backend
  944. OPTION(ALSOFT_REQUIRE_COREAUDIO "Require CoreAudio backend" OFF)
  945. FIND_LIBRARY(COREAUDIO_FRAMEWORK
  946. NAMES CoreAudio
  947. PATHS /System/Library/Frameworks
  948. )
  949. IF(COREAUDIO_FRAMEWORK)
  950. OPTION(ALSOFT_BACKEND_COREAUDIO "Enable CoreAudio backend" ON)
  951. IF(ALSOFT_BACKEND_COREAUDIO)
  952. SET(HAVE_COREAUDIO 1)
  953. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.cpp Alc/backends/coreaudio.h)
  954. SET(BACKENDS "${BACKENDS} CoreAudio,")
  955. SET(EXTRA_LIBS ${COREAUDIO_FRAMEWORK} ${EXTRA_LIBS})
  956. SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS})
  957. SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS})
  958. # Some versions of OSX may need the AudioToolbox framework. Add it if
  959. # it's found.
  960. FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY
  961. NAMES AudioToolbox
  962. PATHS ~/Library/Frameworks
  963. /Library/Frameworks
  964. /System/Library/Frameworks
  965. )
  966. IF(AUDIOTOOLBOX_LIBRARY)
  967. SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS})
  968. ENDIF()
  969. ENDIF()
  970. ENDIF()
  971. IF(ALSOFT_REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO)
  972. MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend")
  973. ENDIF()
  974. # Check for OpenSL (Android) backend
  975. OPTION(ALSOFT_REQUIRE_OPENSL "Require OpenSL backend" OFF)
  976. CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H)
  977. IF(HAVE_SLES_OPENSLES_ANDROID_H)
  978. CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES)
  979. IF(HAVE_LIBOPENSLES)
  980. OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
  981. IF(ALSOFT_BACKEND_OPENSL)
  982. SET(HAVE_OPENSL 1)
  983. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.cpp Alc/backends/opensl.h)
  984. SET(BACKENDS "${BACKENDS} OpenSL,")
  985. SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
  986. ENDIF()
  987. ENDIF()
  988. ENDIF()
  989. IF(ALSOFT_REQUIRE_OPENSL AND NOT HAVE_OPENSL)
  990. MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend")
  991. ENDIF()
  992. # Check for SDL2 backend
  993. OPTION(ALSOFT_REQUIRE_SDL2 "Require SDL2 backend" OFF)
  994. FIND_PACKAGE(SDL2)
  995. IF(SDL2_FOUND)
  996. # Off by default, since it adds a runtime dependency
  997. OPTION(ALSOFT_BACKEND_SDL2 "Enable SDL2 backend" OFF)
  998. IF(ALSOFT_BACKEND_SDL2)
  999. SET(HAVE_SDL2 1)
  1000. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sdl2.cpp Alc/backends/sdl2.h)
  1001. SET(BACKENDS "${BACKENDS} SDL2,")
  1002. SET(EXTRA_LIBS ${SDL2_LIBRARY} ${EXTRA_LIBS})
  1003. SET(INC_PATHS ${INC_PATHS} ${SDL2_INCLUDE_DIR})
  1004. ENDIF()
  1005. ENDIF()
  1006. IF(ALSOFT_REQUIRE_SDL2 AND NOT SDL2_FOUND)
  1007. MESSAGE(FATAL_ERROR "Failed to enabled required SDL2 backend")
  1008. ENDIF()
  1009. # Optionally enable the Wave Writer backend
  1010. OPTION(ALSOFT_BACKEND_WAVE "Enable Wave Writer backend" ON)
  1011. IF(ALSOFT_BACKEND_WAVE)
  1012. SET(HAVE_WAVE 1)
  1013. SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.cpp Alc/backends/wave.h)
  1014. SET(BACKENDS "${BACKENDS} WaveFile,")
  1015. ENDIF()
  1016. # This is always available
  1017. SET(BACKENDS "${BACKENDS} Null")
  1018. FIND_PACKAGE(Git)
  1019. IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
  1020. # Get the current working branch and its latest abbreviated commit hash
  1021. ADD_CUSTOM_TARGET(build_version
  1022. ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
  1023. -D LIB_VERSION=${LIB_VERSION}
  1024. -D SRC=${OpenAL_SOURCE_DIR}/version.h.in
  1025. -D DST=${OpenAL_BINARY_DIR}/version.h
  1026. -P ${OpenAL_SOURCE_DIR}/version.cmake
  1027. WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
  1028. VERBATIM
  1029. )
  1030. ELSE()
  1031. SET(GIT_BRANCH "UNKNOWN")
  1032. SET(GIT_COMMIT_HASH "unknown")
  1033. CONFIGURE_FILE(
  1034. "${OpenAL_SOURCE_DIR}/version.h.in"
  1035. "${OpenAL_BINARY_DIR}/version.h")
  1036. ENDIF()
  1037. SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/native-tools")
  1038. SET(ALSOFT_NATIVE_TOOLS_PATH "" CACHE STRING "Path to prebuilt native tools (leave blank to auto-build)")
  1039. IF(ALSOFT_NATIVE_TOOLS_PATH)
  1040. SET(BIN2H_COMMAND "${ALSOFT_NATIVE_TOOLS_PATH}/bin2h")
  1041. SET(BSINCGEN_COMMAND "${ALSOFT_NATIVE_TOOLS_PATH}/bsincgen")
  1042. ELSE()
  1043. SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools")
  1044. FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}")
  1045. SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}/bin2h")
  1046. SET(BSINCGEN_COMMAND "${NATIVE_BIN_DIR}/bsincgen")
  1047. ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
  1048. COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${NATIVE_SRC_DIR}"
  1049. COMMAND ${CMAKE_COMMAND} -E remove "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
  1050. COMMAND ${CMAKE_COMMAND} --build . --config "Release"
  1051. WORKING_DIRECTORY "${NATIVE_BIN_DIR}"
  1052. DEPENDS "${NATIVE_SRC_DIR}/CMakeLists.txt"
  1053. IMPLICIT_DEPENDS C "${NATIVE_SRC_DIR}/bin2h.c"
  1054. C "${NATIVE_SRC_DIR}/bsincgen.c"
  1055. VERBATIM
  1056. )
  1057. ENDIF()
  1058. ADD_CUSTOM_TARGET(native-tools
  1059. DEPENDS "${BIN2H_COMMAND}" "${BSINCGEN_COMMAND}"
  1060. VERBATIM
  1061. )
  1062. option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" ON)
  1063. if(ALSOFT_EMBED_HRTF_DATA)
  1064. MACRO(make_hrtf_header FILENAME VARNAME)
  1065. SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
  1066. SET(outfile "${OpenAL_BINARY_DIR}/${FILENAME}.h")
  1067. ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
  1068. COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME}
  1069. DEPENDS native-tools "${infile}"
  1070. VERBATIM
  1071. )
  1072. SET(ALC_OBJS ${ALC_OBJS} "${outfile}")
  1073. ENDMACRO()
  1074. make_hrtf_header(default-44100.mhr "hrtf_default_44100")
  1075. make_hrtf_header(default-48000.mhr "hrtf_default_48000")
  1076. endif()
  1077. ADD_CUSTOM_COMMAND(OUTPUT "${OpenAL_BINARY_DIR}/bsinc_inc.h"
  1078. COMMAND "${BSINCGEN_COMMAND}" "${OpenAL_BINARY_DIR}/bsinc_inc.h"
  1079. DEPENDS native-tools "${NATIVE_SRC_DIR}/bsincgen.c"
  1080. VERBATIM
  1081. )
  1082. SET(ALC_OBJS ${ALC_OBJS} "${OpenAL_BINARY_DIR}/bsinc_inc.h")
  1083. IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
  1084. add_subdirectory(utils/alsoft-config)
  1085. ENDIF()
  1086. IF(ALSOFT_EXAMPLES)
  1087. IF(NOT SDL2_FOUND)
  1088. FIND_PACKAGE(SDL2)
  1089. ENDIF()
  1090. IF(SDL2_FOUND)
  1091. FIND_PACKAGE(SDL_sound)
  1092. FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE)
  1093. ENDIF()
  1094. ENDIF()
  1095. IF(NOT WIN32)
  1096. SET(LIBNAME "openal")
  1097. ELSE()
  1098. SET(LIBNAME "OpenAL32")
  1099. ENDIF()
  1100. # Needed for openal.pc.in
  1101. SET(prefix ${CMAKE_INSTALL_PREFIX})
  1102. SET(exec_prefix "\${prefix}")
  1103. SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
  1104. SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
  1105. SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
  1106. SET(PACKAGE_VERSION "${LIB_VERSION}")
  1107. SET(PKG_CONFIG_CFLAGS )
  1108. SET(PKG_CONFIG_PRIVATE_LIBS )
  1109. IF(LIBTYPE STREQUAL "STATIC")
  1110. SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC)
  1111. FOREACH(FLAG ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
  1112. # If this is already a linker flag, or is a full path+file, add it
  1113. # as-is. Otherwise, it's a name intended to be dressed as -lname.
  1114. IF(FLAG MATCHES "^-.*" OR EXISTS "${FLAG}")
  1115. SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} ${FLAG}")
  1116. ELSE()
  1117. SET(PKG_CONFIG_PRIVATE_LIBS "${PKG_CONFIG_PRIVATE_LIBS} -l${FLAG}")
  1118. ENDIF()
  1119. ENDFOREACH()
  1120. ENDIF()
  1121. # End configuration
  1122. CONFIGURE_FILE(
  1123. "${OpenAL_SOURCE_DIR}/config.h.in"
  1124. "${OpenAL_BINARY_DIR}/config.h")
  1125. CONFIGURE_FILE(
  1126. "${OpenAL_SOURCE_DIR}/openal.pc.in"
  1127. "${OpenAL_BINARY_DIR}/openal.pc"
  1128. @ONLY)
  1129. UNSET(HAS_ROUTER)
  1130. SET(IMPL_TARGET OpenAL) # Either OpenAL or soft_oal.
  1131. SET(SUBSYS_FLAG )
  1132. # Build main library
  1133. IF(LIBTYPE STREQUAL "STATIC")
  1134. SET(CPP_DEFS ${CPP_DEFS} AL_LIBTYPE_STATIC)
  1135. IF(WIN32 AND ALSOFT_NO_UID_DEFS)
  1136. SET(CPP_DEFS ${CPP_DEFS} AL_NO_UID_DEFS)
  1137. ENDIF()
  1138. ADD_LIBRARY(OpenAL STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
  1139. ELSE()
  1140. IF(WIN32)
  1141. IF(MSVC)
  1142. SET(SUBSYS_FLAG ${SUBSYS_FLAG} "/SUBSYSTEM:WINDOWS")
  1143. ELSEIF(CMAKE_COMPILER_IS_GNUCC)
  1144. SET(SUBSYS_FLAG ${SUBSYS_FLAG} "-mwindows")
  1145. ENDIF()
  1146. ENDIF()
  1147. IF(WIN32 AND ALSOFT_BUILD_ROUTER)
  1148. ADD_LIBRARY(OpenAL SHARED
  1149. router/router.cpp
  1150. router/router.h
  1151. router/alc.cpp
  1152. router/al.cpp
  1153. ${COMMON_OBJS}
  1154. )
  1155. TARGET_COMPILE_DEFINITIONS(OpenAL
  1156. PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
  1157. TARGET_COMPILE_OPTIONS(OpenAL PRIVATE ${C_FLAGS})
  1158. TARGET_LINK_LIBRARIES(OpenAL PRIVATE ${LINKER_FLAGS})
  1159. TARGET_INCLUDE_DIRECTORIES(OpenAL
  1160. PUBLIC
  1161. $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
  1162. $<INSTALL_INTERFACE:include>
  1163. PRIVATE
  1164. ${OpenAL_SOURCE_DIR}/common
  1165. ${OpenAL_BINARY_DIR}
  1166. )
  1167. SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
  1168. SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME})
  1169. IF(TARGET build_version)
  1170. ADD_DEPENDENCIES(OpenAL build_version)
  1171. ENDIF()
  1172. SET(HAS_ROUTER 1)
  1173. SET(LIBNAME "soft_oal")
  1174. SET(IMPL_TARGET soft_oal)
  1175. ENDIF()
  1176. ADD_LIBRARY(${IMPL_TARGET} SHARED ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
  1177. IF(WIN32)
  1178. SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES PREFIX "")
  1179. ENDIF()
  1180. ENDIF()
  1181. TARGET_LINK_LIBRARIES(${IMPL_TARGET}
  1182. PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
  1183. TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET}
  1184. PUBLIC
  1185. $<BUILD_INTERFACE:${OpenAL_SOURCE_DIR}/include>
  1186. $<INSTALL_INTERFACE:include>
  1187. PRIVATE
  1188. ${INC_PATHS}
  1189. ${OpenAL_BINARY_DIR}
  1190. ${OpenAL_SOURCE_DIR}/Alc
  1191. ${OpenAL_SOURCE_DIR}/OpenAL32/Include
  1192. ${OpenAL_SOURCE_DIR}/common
  1193. )
  1194. SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME}
  1195. VERSION ${LIB_VERSION}
  1196. SOVERSION ${LIB_MAJOR_VERSION}
  1197. )
  1198. TARGET_COMPILE_DEFINITIONS(${IMPL_TARGET}
  1199. PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
  1200. TARGET_COMPILE_OPTIONS(${IMPL_TARGET} PRIVATE ${C_FLAGS})
  1201. IF(TARGET build_version)
  1202. ADD_DEPENDENCIES(${IMPL_TARGET} build_version)
  1203. ENDIF()
  1204. IF(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
  1205. FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
  1206. FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
  1207. IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
  1208. MESSAGE(STATUS "")
  1209. IF(NOT SED_EXECUTABLE)
  1210. MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
  1211. ENDIF()
  1212. IF(NOT DLLTOOL_EXECUTABLE)
  1213. MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
  1214. ENDIF()
  1215. ELSE()
  1216. SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS
  1217. " -Wl,--output-def,OpenAL32.def")
  1218. ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD
  1219. COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
  1220. COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
  1221. COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
  1222. VERBATIM
  1223. )
  1224. ENDIF()
  1225. ENDIF()
  1226. IF(ALSOFT_INSTALL)
  1227. INSTALL(TARGETS OpenAL EXPORT OpenAL
  1228. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1229. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1230. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1231. INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL
  1232. )
  1233. EXPORT(TARGETS OpenAL
  1234. NAMESPACE OpenAL::
  1235. FILE OpenALConfig.cmake)
  1236. INSTALL(EXPORT OpenAL
  1237. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
  1238. NAMESPACE OpenAL::
  1239. FILE OpenALConfig.cmake)
  1240. INSTALL(FILES include/AL/al.h
  1241. include/AL/alc.h
  1242. include/AL/alext.h
  1243. include/AL/efx.h
  1244. include/AL/efx-creative.h
  1245. include/AL/efx-presets.h
  1246. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/AL
  1247. )
  1248. INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
  1249. DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
  1250. IF(TARGET soft_oal)
  1251. INSTALL(TARGETS soft_oal
  1252. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1253. )
  1254. ENDIF()
  1255. ENDIF()
  1256. if(HAS_ROUTER)
  1257. message(STATUS "")
  1258. message(STATUS "Building DLL router")
  1259. endif()
  1260. MESSAGE(STATUS "")
  1261. MESSAGE(STATUS "Building OpenAL with support for the following backends:")
  1262. MESSAGE(STATUS " ${BACKENDS}")
  1263. MESSAGE(STATUS "")
  1264. MESSAGE(STATUS "Building with support for CPU extensions:")
  1265. MESSAGE(STATUS " ${CPU_EXTS}")
  1266. MESSAGE(STATUS "")
  1267. IF(FPMATH_SET)
  1268. MESSAGE(STATUS "Building with SSE${FPMATH_SET} codegen")
  1269. MESSAGE(STATUS "")
  1270. ENDIF()
  1271. IF(WIN32)
  1272. IF(NOT HAVE_DSOUND)
  1273. MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
  1274. MESSAGE(STATUS " This is probably NOT what you want!")
  1275. MESSAGE(STATUS "")
  1276. ENDIF()
  1277. ENDIF()
  1278. if(ALSOFT_EMBED_HRTF_DATA)
  1279. message(STATUS "Embedding HRTF datasets")
  1280. message(STATUS "")
  1281. endif()
  1282. # Install alsoft.conf configuration file
  1283. IF(ALSOFT_CONFIG)
  1284. INSTALL(FILES alsoftrc.sample
  1285. DESTINATION ${CMAKE_INSTALL_DATADIR}/openal
  1286. )
  1287. MESSAGE(STATUS "Installing sample configuration")
  1288. MESSAGE(STATUS "")
  1289. ENDIF()
  1290. # Install HRTF definitions
  1291. IF(ALSOFT_HRTF_DEFS)
  1292. INSTALL(FILES hrtf/default-44100.mhr
  1293. hrtf/default-48000.mhr
  1294. DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/hrtf
  1295. )
  1296. MESSAGE(STATUS "Installing HRTF definitions")
  1297. MESSAGE(STATUS "")
  1298. ENDIF()
  1299. # Install AmbDec presets
  1300. IF(ALSOFT_AMBDEC_PRESETS)
  1301. INSTALL(FILES presets/3D7.1.ambdec
  1302. presets/hexagon.ambdec
  1303. presets/itu5.1.ambdec
  1304. presets/itu5.1-nocenter.ambdec
  1305. presets/rectangle.ambdec
  1306. presets/square.ambdec
  1307. presets/presets.txt
  1308. DESTINATION ${CMAKE_INSTALL_DATADIR}/openal/presets
  1309. )
  1310. MESSAGE(STATUS "Installing AmbDec presets")
  1311. MESSAGE(STATUS "")
  1312. ENDIF()
  1313. IF(ALSOFT_UTILS)
  1314. set(UTIL_TARGETS )
  1315. ADD_EXECUTABLE(openal-info utils/openal-info.c)
  1316. TARGET_INCLUDE_DIRECTORIES(openal-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
  1317. TARGET_COMPILE_OPTIONS(openal-info PRIVATE ${C_FLAGS})
  1318. TARGET_LINK_LIBRARIES(openal-info PRIVATE ${LINKER_FLAGS} OpenAL)
  1319. set(UTIL_TARGETS ${UTIL_TARGETS} openal-info)
  1320. find_package(MySOFA)
  1321. if(MYSOFA_FOUND)
  1322. set(MAKEMHR_SRCS
  1323. utils/makemhr/loaddef.cpp
  1324. utils/makemhr/loaddef.h
  1325. utils/makemhr/loadsofa.cpp
  1326. utils/makemhr/loadsofa.h
  1327. utils/makemhr/makemhr.cpp
  1328. utils/makemhr/makemhr.h)
  1329. if(NOT HAVE_GETOPT)
  1330. set(MAKEMHR_SRCS ${MAKEMHR_SRCS} utils/getopt.c utils/getopt.h)
  1331. endif()
  1332. add_executable(makemhr ${MAKEMHR_SRCS})
  1333. target_compile_definitions(makemhr PRIVATE ${CPP_DEFS})
  1334. target_include_directories(makemhr
  1335. PRIVATE ${OpenAL_SOURCE_DIR}/common ${OpenAL_BINARY_DIR})
  1336. target_compile_options(makemhr PRIVATE ${C_FLAGS})
  1337. target_link_libraries(makemhr PRIVATE ${LINKER_FLAGS} MySOFA::MySOFA)
  1338. set(UTIL_TARGETS ${UTIL_TARGETS} makemhr)
  1339. set(SOFAINFO_SRCS utils/sofa-info.cpp)
  1340. add_executable(sofa-info ${SOFAINFO_SRCS})
  1341. target_compile_definitions(sofa-info PRIVATE ${CPP_DEFS})
  1342. target_include_directories(sofa-info PRIVATE ${OpenAL_SOURCE_DIR}/common)
  1343. target_compile_options(sofa-info PRIVATE ${C_FLAGS})
  1344. target_link_libraries(sofa-info PRIVATE ${LINKER_FLAGS} MySOFA::MySOFA)
  1345. endif()
  1346. IF(ALSOFT_INSTALL)
  1347. INSTALL(TARGETS ${UTIL_TARGETS}
  1348. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1349. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1350. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1351. )
  1352. ENDIF()
  1353. MESSAGE(STATUS "Building utility programs")
  1354. IF(TARGET alsoft-config)
  1355. MESSAGE(STATUS "Building configuration program")
  1356. ENDIF()
  1357. MESSAGE(STATUS "")
  1358. ENDIF()
  1359. IF(ALSOFT_TESTS)
  1360. ADD_EXECUTABLE(altonegen
  1361. examples/altonegen.c
  1362. examples/common/alhelpers.c
  1363. )
  1364. TARGET_COMPILE_DEFINITIONS(altonegen PRIVATE ${CPP_DEFS})
  1365. TARGET_INCLUDE_DIRECTORIES(altonegen PRIVATE ${OpenAL_SOURCE_DIR}/common)
  1366. TARGET_COMPILE_OPTIONS(altonegen PRIVATE ${C_FLAGS})
  1367. TARGET_LINK_LIBRARIES(altonegen PRIVATE ${LINKER_FLAGS} OpenAL ${MATH_LIB})
  1368. IF(ALSOFT_INSTALL)
  1369. INSTALL(TARGETS altonegen
  1370. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1371. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1372. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1373. )
  1374. ENDIF()
  1375. MESSAGE(STATUS "Building test programs")
  1376. MESSAGE(STATUS "")
  1377. ENDIF()
  1378. IF(ALSOFT_EXAMPLES)
  1379. # Add a static library with common functions used by multiple targets
  1380. ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c)
  1381. TARGET_COMPILE_DEFINITIONS(ex-common PUBLIC ${CPP_DEFS})
  1382. TARGET_INCLUDE_DIRECTORIES(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common)
  1383. TARGET_COMPILE_OPTIONS(ex-common PUBLIC ${C_FLAGS})
  1384. TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL)
  1385. ADD_EXECUTABLE(alrecord examples/alrecord.c)
  1386. TARGET_LINK_LIBRARIES(alrecord PRIVATE ${LINKER_FLAGS} ex-common)
  1387. IF(ALSOFT_INSTALL)
  1388. INSTALL(TARGETS alrecord
  1389. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1390. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1391. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1392. )
  1393. ENDIF()
  1394. MESSAGE(STATUS "Building example programs")
  1395. IF(SDL2_FOUND)
  1396. IF(SDL_SOUND_FOUND)
  1397. ADD_EXECUTABLE(alplay examples/alplay.c)
  1398. TARGET_INCLUDE_DIRECTORIES(alplay
  1399. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1400. TARGET_LINK_LIBRARIES(alplay
  1401. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
  1402. ADD_EXECUTABLE(alstream examples/alstream.c)
  1403. TARGET_INCLUDE_DIRECTORIES(alstream
  1404. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1405. TARGET_LINK_LIBRARIES(alstream
  1406. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
  1407. ADD_EXECUTABLE(alreverb examples/alreverb.c)
  1408. TARGET_INCLUDE_DIRECTORIES(alreverb
  1409. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1410. TARGET_LINK_LIBRARIES(alreverb
  1411. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
  1412. ADD_EXECUTABLE(almultireverb examples/almultireverb.c)
  1413. TARGET_INCLUDE_DIRECTORIES(almultireverb
  1414. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1415. TARGET_LINK_LIBRARIES(almultireverb
  1416. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common
  1417. ${MATH_LIB})
  1418. ADD_EXECUTABLE(allatency examples/allatency.c)
  1419. TARGET_INCLUDE_DIRECTORIES(allatency
  1420. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1421. TARGET_LINK_LIBRARIES(allatency
  1422. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common)
  1423. ADD_EXECUTABLE(alloopback examples/alloopback.c)
  1424. TARGET_INCLUDE_DIRECTORIES(alloopback
  1425. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1426. TARGET_LINK_LIBRARIES(alloopback
  1427. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
  1428. ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
  1429. TARGET_INCLUDE_DIRECTORIES(alhrtf
  1430. PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
  1431. TARGET_LINK_LIBRARIES(alhrtf
  1432. PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ex-common ${MATH_LIB})
  1433. IF(ALSOFT_INSTALL)
  1434. INSTALL(TARGETS alplay alstream alreverb almultireverb allatency alloopback alhrtf
  1435. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1436. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1437. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1438. )
  1439. ENDIF()
  1440. MESSAGE(STATUS "Building SDL_sound example programs")
  1441. ENDIF()
  1442. SET(FFVER_OK FALSE)
  1443. IF(FFMPEG_FOUND)
  1444. SET(FFVER_OK TRUE)
  1445. IF(AVFORMAT_VERSION VERSION_LESS "57.56.101")
  1446. MESSAGE(STATUS "libavformat is too old! (${AVFORMAT_VERSION}, wanted 57.56.101)")
  1447. SET(FFVER_OK FALSE)
  1448. ENDIF()
  1449. IF(AVCODEC_VERSION VERSION_LESS "57.64.101")
  1450. MESSAGE(STATUS "libavcodec is too old! (${AVCODEC_VERSION}, wanted 57.64.101)")
  1451. SET(FFVER_OK FALSE)
  1452. ENDIF()
  1453. IF(AVUTIL_VERSION VERSION_LESS "55.34.101")
  1454. MESSAGE(STATUS "libavutil is too old! (${AVUTIL_VERSION}, wanted 55.34.101)")
  1455. SET(FFVER_OK FALSE)
  1456. ENDIF()
  1457. IF(SWSCALE_VERSION VERSION_LESS "4.2.100")
  1458. MESSAGE(STATUS "libswscale is too old! (${SWSCALE_VERSION}, wanted 4.2.100)")
  1459. SET(FFVER_OK FALSE)
  1460. ENDIF()
  1461. IF(SWRESAMPLE_VERSION VERSION_LESS "2.3.100")
  1462. MESSAGE(STATUS "libswresample is too old! (${SWRESAMPLE_VERSION}, wanted 2.3.100)")
  1463. SET(FFVER_OK FALSE)
  1464. ENDIF()
  1465. ENDIF()
  1466. IF(FFVER_OK)
  1467. ADD_EXECUTABLE(alffplay examples/alffplay.cpp)
  1468. TARGET_INCLUDE_DIRECTORIES(alffplay
  1469. PRIVATE ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
  1470. TARGET_LINK_LIBRARIES(alffplay
  1471. PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ex-common)
  1472. IF(ALSOFT_INSTALL)
  1473. INSTALL(TARGETS alffplay
  1474. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  1475. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1476. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1477. )
  1478. ENDIF()
  1479. MESSAGE(STATUS "Building SDL+FFmpeg example programs")
  1480. ENDIF()
  1481. MESSAGE(STATUS "")
  1482. ENDIF()
  1483. ENDIF()