Use a separate flag to mark buffer initialization
[dsound-openal.git] / CMakeLists.txt
blob3f2f0c8acefbeb748c79aae02f957142a557eb4c
1 cmake_minimum_required(VERSION 3.0.2)
3 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 include(CheckCCompilerFlag)
6 include(CheckCSourceCompiles)
7 include(CheckTypeSize)
8 include(CheckIncludeFile)
10 project(DSOAL C)
13 IF(NOT CMAKE_BUILD_TYPE)
14     SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
15         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
16         FORCE)
17 ENDIF()
19 set(DSOAL_DEFS "")
20 set(DSOAL_INC "")
21 set(DSOAL_FLAGS "")
22 set(DSOAL_LIBS "")
24 set(DSOAL_OBJS buffer.c
25                capture.c
26                dsound8.c
27                dsound_main.c
28                dsound_private.h
29                duplex.c
30                eax.c
31                eax.h
32                primary.c
33                propset.c)
35 set(DSOAL_INC ${DSOAL_INC} ${DSOAL_BINARY_DIR} ${DSOAL_SOURCE_DIR}/include/AL)
38 check_type_size("long" SIZEOF_LONG)
39 set(DSOAL_DEFS ${DSOAL_DEFS} "SIZEOF_LONG=${SIZEOF_LONG}")
41 check_c_source_compiles("#include <intrin.h>
42 int main()
44     unsigned long idx = 0;
45     _BitScanForward64(&idx, 1);
46     return idx;
47 }" HAVE_BITSCANFORWARD64_INTRINSIC)
48 if(HAVE_BITSCANFORWARD64_INTRINSIC)
49     set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD64_INTRINSIC)
50 else()
51     check_c_source_compiles("#include <intrin.h>
52     int main()
53     {
54         unsigned long idx = 0;
55         _BitScanForward(&idx, 1);
56         return idx;
57     }" HAVE_BITSCANFORWARD_INTRINSIC)
58     if(HAVE_BITSCANFORWARD_INTRINSIC)
59         set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD_INTRINSIC)
60     endif()
61 endif()
64 if(NOT MSVC)
65     set(DSOAL_FLAGS ${DSOAL_FLAGS} -Winline -Wall)
66     check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
67     if(HAVE_W_EXTRA)
68         set(DSOAL_FLAGS ${DSOAL_FLAGS} -Wextra)
69     endif()
70     set(DSOAL_LIBS ${DSOAL_LIBS} -static-libgcc)
71 endif()
72 if(NOT WIN32)
73     check_c_compiler_flag(-fvisibility=hidden HAVE_FVISIBILITY_HIDDEN)
74     if(HAVE_FVISIBILITY_HIDDEN)
75         set(DSOAL_FLAGS ${DSOAL_FLAGS} -fvisibility=hidden)
76     endif()
77 else()
78     if(MINGW)
79         set(CMAKE_RC_COMPILER_INIT windres)
80         set(CMAKE_RC_COMPILE_OBJECT
81             "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
82     endif(MINGW)
83     enable_language(RC)
85     set(DSOAL_OBJS ${DSOAL_OBJS} debug.c version.rc)
87     set(DSOAL_DEFS ${DSOAL_DEFS} _WIN32 WINVER=0x0600 DEBUG_INFO)
89     set(DSOAL_LIBS ${DSOAL_LIBS} winmm ole32)
90 endif()
91 set(DSOAL_DEFS ${DSOAL_DEFS} COBJMACROS)
93 add_library(dsound SHARED ${DSOAL_OBJS} dsound.def)
94 if(WIN32)
95     set_target_properties(dsound PROPERTIES PREFIX "")
96 endif()
97 target_compile_definitions(dsound PRIVATE ${DSOAL_DEFS})
98 target_include_directories(dsound PRIVATE ${DSOAL_INC})
99 target_compile_options(dsound PRIVATE ${DSOAL_FLAGS})
100 target_link_libraries(dsound PRIVATE ${DSOAL_LIBS})