CMakeLists.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. # CMake build file list for OpenAL
  2. CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
  3. IF(COMMAND CMAKE_POLICY)
  4. CMAKE_POLICY(SET CMP0003 NEW)
  5. ENDIF(COMMAND CMAKE_POLICY)
  6. SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
  7. INCLUDE(CheckFunctionExists)
  8. INCLUDE(CheckLibraryExists)
  9. INCLUDE(CheckSharedLibraryExists)
  10. INCLUDE(CheckIncludeFile)
  11. INCLUDE(CheckIncludeFiles)
  12. INCLUDE(CheckSymbolExists)
  13. INCLUDE(CheckCCompilerFlag)
  14. INCLUDE(CheckCSourceCompiles)
  15. INCLUDE(CheckTypeSize)
  16. PROJECT(OpenAL C)
  17. SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
  18. OPTION(ALSA "Check for ALSA backend" ON)
  19. OPTION(OSS "Check for OSS backend" ON)
  20. OPTION(SOLARIS "Check for Solaris backend" ON)
  21. OPTION(DSOUND "Check for DirectSound backend" ON)
  22. OPTION(WINMM "Check for Windows Multimedia backend" ON)
  23. OPTION(PORTAUDIO "Check for PortAudio backend" ON)
  24. OPTION(PULSEAUDIO "Check for PulseAudio backend" ON)
  25. OPTION(WAVE "Enable Wave Writer backend" ON)
  26. OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
  27. OPTION(WERROR "Treat compile warnings as errors" OFF)
  28. OPTION(UTILS "Build and install utility programs" ON)
  29. OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF)
  30. IF(WIN32)
  31. SET(LIBNAME OpenAL32)
  32. ADD_DEFINITIONS("-D_WIN32")
  33. ELSE()
  34. SET(LIBNAME openal)
  35. ENDIF()
  36. IF(NOT LIBTYPE)
  37. SET(LIBTYPE SHARED)
  38. ENDIF()
  39. SET(LIB_MAJOR_VERSION "1")
  40. SET(LIB_MINOR_VERSION "13")
  41. SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
  42. CHECK_TYPE_SIZE("long" SIZEOF_LONG)
  43. CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
  44. CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
  45. CHECK_TYPE_SIZE("void*" SIZEOF_VOIDP)
  46. # Add definitions, compiler switches, etc.
  47. INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
  48. IF(NOT CMAKE_BUILD_TYPE)
  49. SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  50. "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
  51. FORCE)
  52. ENDIF()
  53. IF(NOT CMAKE_DEBUG_POSTFIX)
  54. SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
  55. "Library postfix for debug builds. Normally left blank."
  56. FORCE)
  57. ENDIF()
  58. IF(MSVC)
  59. # ???
  60. SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
  61. SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
  62. SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
  63. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
  64. ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
  65. ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
  66. IF(NOT DXSDK_DIR)
  67. STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
  68. ELSE()
  69. STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
  70. ENDIF()
  71. IF(DXSDK_DIR)
  72. MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
  73. SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
  74. INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
  75. LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
  76. ENDIF()
  77. OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
  78. IF(FORCE_STATIC_VCRT)
  79. FOREACH(flag_var
  80. CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
  81. CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
  82. IF(${flag_var} MATCHES "/MD")
  83. STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
  84. ENDIF()
  85. ENDFOREACH(flag_var)
  86. ENDIF()
  87. ELSE()
  88. ADD_DEFINITIONS(-Winline -Wall)
  89. CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
  90. IF(HAVE_W_EXTRA)
  91. ADD_DEFINITIONS(-Wextra)
  92. ENDIF()
  93. IF(WERROR)
  94. ADD_DEFINITIONS(-Werror)
  95. ENDIF()
  96. SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING
  97. "Flags used by the compiler during Release with Debug Info builds."
  98. FORCE)
  99. SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
  100. "Flags used by the compiler during release minsize builds."
  101. FORCE)
  102. SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING
  103. "Flags used by the compiler during release builds"
  104. FORCE)
  105. SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
  106. "Flags used by the compiler during debug builds."
  107. FORCE)
  108. CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
  109. int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
  110. # Set visibility options if available
  111. IF(NOT WIN32)
  112. CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_SWITCH)
  113. IF(HAVE_VISIBILITY_SWITCH)
  114. CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
  115. int main() {return 0;}" HAVE_GCC_VISIBILITY)
  116. IF(HAVE_GCC_VISIBILITY)
  117. ADD_DEFINITIONS(-fvisibility=internal -DHAVE_GCC_VISIBILITY)
  118. ENDIF()
  119. ENDIF()
  120. ENDIF()
  121. ENDIF()
  122. CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
  123. int main() {return 0;}" HAVE_GCC_FORMAT)
  124. CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
  125. CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
  126. CHECK_LIBRARY_EXISTS(m powf "" HAVE_POWF)
  127. CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF)
  128. CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF)
  129. CHECK_LIBRARY_EXISTS(m atanf "" HAVE_ATANF)
  130. CHECK_LIBRARY_EXISTS(m fabsf "" HAVE_FABSF)
  131. IF(HAVE_FENV_H)
  132. CHECK_LIBRARY_EXISTS(m fesetround "" HAVE_FESETROUND)
  133. ENDIF()
  134. IF(HAVE_SQRTF OR HAVE_ACOSF OR HAVE_ATANF OR HAVE_FABSF OR HAVE_FESETROUND)
  135. SET(EXTRA_LIBS m ${EXTRA_LIBS})
  136. ENDIF()
  137. CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
  138. CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)
  139. CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
  140. CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
  141. IF(NOT HAVE_STRCASECMP)
  142. CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
  143. IF(NOT HAVE__STRICMP)
  144. MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
  145. ENDIF()
  146. ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
  147. ENDIF()
  148. CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
  149. IF(NOT HAVE_STRNCASECMP)
  150. CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
  151. IF(NOT HAVE__STRNICMP)
  152. MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
  153. ENDIF()
  154. ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
  155. ENDIF()
  156. CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
  157. IF(NOT HAVE_SNPRINTF)
  158. CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
  159. IF(NOT HAVE__SNPRINTF)
  160. MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
  161. ENDIF()
  162. ADD_DEFINITIONS(-Dsnprintf=_snprintf)
  163. ENDIF()
  164. CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
  165. IF(NOT HAVE_VSNPRINTF)
  166. CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
  167. IF(NOT HAVE__VSNPRINTF)
  168. MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
  169. ENDIF()
  170. ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
  171. ENDIF()
  172. CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
  173. IF(NOT HAVE_ISNAN)
  174. CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
  175. IF(NOT HAVE__ISNAN)
  176. MESSAGE(FATAL_ERROR "No isnan function found, please report!")
  177. ENDIF()
  178. ADD_DEFINITIONS(-Disnan=_isnan)
  179. ENDIF()
  180. # Check for the dlopen API (for dynamicly loading backend libs)
  181. IF(DLOPEN)
  182. CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
  183. IF(HAVE_DLFCN_H)
  184. CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
  185. IF(HAVE_LIBDL)
  186. SET(EXTRA_LIBS dl ${EXTRA_LIBS})
  187. ENDIF()
  188. ENDIF()
  189. ENDIF()
  190. # Check if we have Windows headers
  191. CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
  192. IF(NOT HAVE_WINDOWS_H)
  193. CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
  194. IF(NOT HAVE_GETTIMEOFDAY)
  195. MESSAGE(FATAL_ERROR "No timing function found!")
  196. ENDIF()
  197. CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
  198. IF(NOT HAVE_NANOSLEEP)
  199. MESSAGE(FATAL_ERROR "No sleep function found!")
  200. ENDIF()
  201. CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
  202. IF(HAVE_PTHREAD)
  203. ADD_DEFINITIONS(-pthread)
  204. SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
  205. ENDIF()
  206. # We need pthreads outside of Windows
  207. CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
  208. IF(NOT HAVE_PTHREAD_H)
  209. MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
  210. ENDIF()
  211. # Some systems need pthread_np.h to get recursive mutexes
  212. CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
  213. # _GNU_SOURCE is needed on some systems for extra attributes, and
  214. # _REENTRANT is needed for libc thread-safety
  215. ADD_DEFINITIONS(-D_GNU_SOURCE=1)
  216. CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
  217. IF(HAVE_LIBPTHREAD)
  218. SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
  219. ENDIF()
  220. CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM)
  221. CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
  222. IF(HAVE_LIBRT)
  223. SET(EXTRA_LIBS rt ${EXTRA_LIBS})
  224. ENDIF()
  225. ENDIF()
  226. # Check for a 64-bit type
  227. CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
  228. IF(NOT HAVE_STDINT_H)
  229. IF(HAVE_WINDOWS_H)
  230. CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0500
  231. \#include <windows.h>
  232. __int64 foo;
  233. int main() {return 0;}" HAVE___INT64)
  234. ENDIF()
  235. IF(NOT HAVE___INT64)
  236. IF(NOT SIZEOF_LONG MATCHES "8")
  237. IF(NOT SIZEOF_LONG_LONG MATCHES "8")
  238. MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
  239. ENDIF()
  240. ENDIF()
  241. ENDIF()
  242. ENDIF()
  243. IF(WIN32)
  244. # Windows needs winmm for timeGetTime, even if the backend is disabled
  245. CHECK_SHARED_LIBRARY_EXISTS(winmm timeGetTime 0 "" HAVE_LIBWINMM)
  246. IF(HAVE_LIBWINMM)
  247. SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
  248. SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm)
  249. ENDIF()
  250. ENDIF()
  251. SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
  252. OpenAL32/alBuffer.c
  253. OpenAL32/alDatabuffer.c
  254. OpenAL32/alEffect.c
  255. OpenAL32/alError.c
  256. OpenAL32/alExtension.c
  257. OpenAL32/alFilter.c
  258. OpenAL32/alListener.c
  259. OpenAL32/alSource.c
  260. OpenAL32/alState.c
  261. OpenAL32/alThunk.c
  262. )
  263. SET(ALC_OBJS Alc/ALc.c
  264. Alc/ALu.c
  265. Alc/alcConfig.c
  266. Alc/alcEcho.c
  267. Alc/alcModulator.c
  268. Alc/alcReverb.c
  269. Alc/alcRing.c
  270. Alc/alcThread.c
  271. Alc/bs2b.c
  272. Alc/mixer.c
  273. Alc/panning.c
  274. Alc/null.c
  275. )
  276. SET(BACKENDS "")
  277. SET(HAVE_ALSA 0)
  278. SET(HAVE_OSS 0)
  279. SET(HAVE_SOLARIS 0)
  280. SET(HAVE_DSOUND 0)
  281. SET(HAVE_WINMM 0)
  282. SET(HAVE_PORTAUDIO 0)
  283. SET(HAVE_PULSEAUDIO 0)
  284. SET(HAVE_WAVE 0)
  285. # Check ALSA backend
  286. IF(ALSA)
  287. CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
  288. IF(HAVE_ALSA_ASOUNDLIB_H)
  289. CHECK_SHARED_LIBRARY_EXISTS(asound snd_pcm_open 4 "" HAVE_LIBASOUND)
  290. IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32)
  291. SET(HAVE_ALSA 1)
  292. SET(ALC_OBJS ${ALC_OBJS} Alc/alsa.c)
  293. IF(HAVE_DLFCN_H OR WIN32)
  294. SET(BACKENDS "${BACKENDS} ALSA,")
  295. ELSE()
  296. SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
  297. SET(EXTRA_LIBS asound ${EXTRA_LIBS})
  298. ENDIF()
  299. ENDIF()
  300. ENDIF()
  301. ENDIF()
  302. # Check OSS backend
  303. IF(OSS)
  304. CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
  305. IF(HAVE_SYS_SOUNDCARD_H)
  306. SET(HAVE_OSS 1)
  307. SET(ALC_OBJS ${ALC_OBJS} Alc/oss.c)
  308. SET(BACKENDS "${BACKENDS} OSS,")
  309. ENDIF()
  310. ENDIF()
  311. # Check Solaris backend
  312. IF(SOLARIS)
  313. CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
  314. IF(HAVE_SYS_AUDIOIO_H)
  315. SET(HAVE_SOLARIS 1)
  316. SET(ALC_OBJS ${ALC_OBJS} Alc/solaris.c)
  317. SET(BACKENDS "${BACKENDS} Solaris,")
  318. ENDIF()
  319. ENDIF()
  320. # Check DSound/MMSystem backend
  321. IF(DSOUND)
  322. CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
  323. IF(HAVE_DSOUND_H)
  324. CHECK_SHARED_LIBRARY_EXISTS(dsound DirectSoundCreate 3 "" HAVE_LIBDSOUND)
  325. IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32)
  326. SET(HAVE_DSOUND 1)
  327. SET(ALC_OBJS ${ALC_OBJS} Alc/dsound.c)
  328. IF(HAVE_DLFCN_H OR WIN32)
  329. SET(BACKENDS "${BACKENDS} DirectSound,")
  330. ELSE()
  331. SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
  332. SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
  333. ENDIF()
  334. ENDIF()
  335. ENDIF()
  336. ENDIF()
  337. IF(HAVE_WINDOWS_H)
  338. IF(WINMM)
  339. CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0500)
  340. IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM)
  341. SET(HAVE_WINMM 1)
  342. SET(ALC_OBJS ${ALC_OBJS} Alc/winmm.c)
  343. SET(BACKENDS "${BACKENDS} WinMM,")
  344. ENDIF()
  345. ENDIF()
  346. ENDIF()
  347. # Check PortAudio backend
  348. IF(PORTAUDIO)
  349. CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
  350. IF(HAVE_PORTAUDIO_H)
  351. CHECK_SHARED_LIBRARY_EXISTS(portaudio Pa_Initialize 0 "" HAVE_LIBPORTAUDIO)
  352. IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32)
  353. SET(HAVE_PORTAUDIO 1)
  354. SET(ALC_OBJS ${ALC_OBJS} Alc/portaudio.c)
  355. IF(HAVE_DLFCN_H OR WIN32)
  356. SET(BACKENDS "${BACKENDS} PortAudio,")
  357. ELSE()
  358. SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
  359. SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
  360. ENDIF()
  361. ENDIF()
  362. ENDIF()
  363. ENDIF()
  364. # Check PortAudio backend
  365. IF(PULSEAUDIO)
  366. CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
  367. IF(HAVE_PULSE_PULSEAUDIO_H)
  368. CHECK_SHARED_LIBRARY_EXISTS(pulse pa_context_new 2 "" HAVE_LIBPULSE)
  369. IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32)
  370. SET(HAVE_PULSEAUDIO 1)
  371. SET(ALC_OBJS ${ALC_OBJS} Alc/pulseaudio.c)
  372. IF(HAVE_DLFCN_H OR WIN32)
  373. SET(BACKENDS "${BACKENDS} PulseAudio,")
  374. ELSE()
  375. SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
  376. SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
  377. ENDIF()
  378. ENDIF()
  379. ENDIF()
  380. ENDIF()
  381. # Optionally enable the Wave Writer backend
  382. IF(WAVE)
  383. SET(HAVE_WAVE 1)
  384. SET(ALC_OBJS ${ALC_OBJS} Alc/wave.c)
  385. SET(BACKENDS "${BACKENDS} WaveFile,")
  386. ENDIF()
  387. # This is always available
  388. SET(BACKENDS "${BACKENDS} Null")
  389. IF(LIBTYPE STREQUAL "STATIC")
  390. ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
  391. SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
  392. ENDIF()
  393. # Needed for openal.pc.in
  394. SET(prefix ${CMAKE_INSTALL_PREFIX})
  395. SET(exec_prefix "\${prefix}")
  396. SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
  397. SET(bindir "\${exec_prefix}/bin")
  398. SET(includedir "\${prefix}/include")
  399. SET(PACKAGE_VERSION "${LIB_VERSION}")
  400. # End configuration
  401. CONFIGURE_FILE(
  402. "${OpenAL_SOURCE_DIR}/config.h.in"
  403. "${OpenAL_BINARY_DIR}/config.h")
  404. CONFIGURE_FILE(
  405. "${OpenAL_SOURCE_DIR}/openal.pc.in"
  406. "${OpenAL_BINARY_DIR}/openal.pc"
  407. @ONLY)
  408. # Build a library
  409. ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
  410. SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY
  411. COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES
  412. VERSION ${LIB_VERSION}.0
  413. SOVERSION ${LIB_MAJOR_VERSION})
  414. IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
  415. SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
  416. ENDIF()
  417. TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
  418. # Add an install target here
  419. INSTALL(TARGETS ${LIBNAME}
  420. RUNTIME DESTINATION bin
  421. LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  422. ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
  423. )
  424. INSTALL(FILES include/AL/al.h
  425. include/AL/alc.h
  426. include/AL/alext.h
  427. include/AL/efx.h
  428. include/AL/efx-creative.h
  429. DESTINATION include/AL
  430. )
  431. INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc"
  432. DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
  433. MESSAGE(STATUS "")
  434. MESSAGE(STATUS "Building OpenAL with support for the following backends:")
  435. MESSAGE(STATUS " ${BACKENDS}")
  436. MESSAGE(STATUS "")
  437. IF(WIN32)
  438. IF(NOT HAVE_DSOUND)
  439. MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
  440. MESSAGE(STATUS " This is probably NOT what you want!")
  441. MESSAGE(STATUS "")
  442. ENDIF()
  443. ENDIF()
  444. # Install alsoft.conf configuration file
  445. IF(ALSOFT_CONFIG)
  446. INSTALL(FILES alsoftrc.sample
  447. DESTINATION /etc/openal
  448. RENAME alsoft.conf
  449. )
  450. MESSAGE(STATUS "Installing sample alsoft.conf")
  451. MESSAGE(STATUS "")
  452. ENDIF()
  453. IF(UTILS)
  454. ADD_EXECUTABLE(openal-info utils/openal-info.c)
  455. TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
  456. INSTALL(TARGETS openal-info
  457. RUNTIME DESTINATION bin
  458. LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  459. ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
  460. )
  461. MESSAGE(STATUS "Building utility programs")
  462. MESSAGE(STATUS "")
  463. ENDIF()