forked from kcat/dsoal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
128 lines (109 loc) · 3.6 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required(VERSION 3.0.2)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckTypeSize)
include(CheckIncludeFile)
project(DSOAL C)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF()
set(DSOAL_DEFS "")
set(DSOAL_INC "")
set(DSOAL_FLAGS "")
set(DSOAL_LIBS "")
set(DSOAL_OBJS buffer.c
capture.c
chorus.c
dsound8.c
dsound_main.c
dsound_private.h
duplex.c
eax.c
eax4.c
eax.h
eax3.h
eax4.h
eax-presets.h
primary.c
propset.c
reverb.c)
set(DSOAL_INC ${DSOAL_INC} ${DSOAL_BINARY_DIR} ${DSOAL_SOURCE_DIR}/include/AL)
check_type_size("long" SIZEOF_LONG)
set(DSOAL_DEFS ${DSOAL_DEFS} "SIZEOF_LONG=${SIZEOF_LONG}")
check_c_source_compiles("#include <intrin.h>
int main()
{
unsigned long idx = 0;
_BitScanForward64(&idx, 1);
return idx;
}" HAVE_BITSCANFORWARD64_INTRINSIC)
if(HAVE_BITSCANFORWARD64_INTRINSIC)
set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD64_INTRINSIC)
else()
check_c_source_compiles("#include <intrin.h>
int main()
{
unsigned long idx = 0;
_BitScanForward(&idx, 1);
return idx;
}" HAVE_BITSCANFORWARD_INTRINSIC)
if(HAVE_BITSCANFORWARD_INTRINSIC)
set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD_INTRINSIC)
endif()
endif()
# MSVC workaround for C99 inline
if(MSVC)
check_c_source_compiles("inline void foo(void) { }
int main() {return 0;}" HAVE_INLINE)
if(NOT HAVE_INLINE)
check_c_source_compiles("__inline void foo(void) { }
int main() {return 0;}" HAVE___INLINE)
if(NOT HAVE___INLINE)
message(FATAL_ERROR "No inline keyword found, please update your MSVC version!")
endif()
set(DSOAL_DEFS ${DSOAL_DEFS} inline=__inline)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
endif()
endif()
if(NOT MSVC)
set(DSOAL_FLAGS ${DSOAL_FLAGS} -Winline -Wall)
check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
if(HAVE_W_EXTRA)
set(DSOAL_FLAGS ${DSOAL_FLAGS} -Wextra)
endif()
set(DSOAL_LIBS ${DSOAL_LIBS} -static-libgcc)
endif()
if(NOT WIN32)
check_c_compiler_flag(-fvisibility=hidden HAVE_FVISIBILITY_HIDDEN)
if(HAVE_FVISIBILITY_HIDDEN)
set(DSOAL_FLAGS ${DSOAL_FLAGS} -fvisibility=hidden)
endif()
else()
if(MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
set(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif(MINGW)
enable_language(RC)
set(DSOAL_OBJS ${DSOAL_OBJS} debug.c version.rc)
set(DSOAL_DEFS ${DSOAL_DEFS} _WIN32 WINVER=0x0600 DEBUG_INFO)
set(DSOAL_LIBS ${DSOAL_LIBS} winmm ole32)
endif()
set(DSOAL_DEFS ${DSOAL_DEFS} COBJMACROS)
if(MSVC)
add_library(dsound SHARED ${DSOAL_OBJS} msvc.def)
set(DSOAL_DEFS ${DSOAL_DEFS} _CRT_SECURE_NO_WARNINGS)
set(DSOAL_FLAGS ${DSOAL_FLAGS} /W3 /wd4090 /wd4113)
else()
add_library(dsound SHARED ${DSOAL_OBJS} mingw.def)
endif(MSVC)
if(WIN32)
set_target_properties(dsound PROPERTIES PREFIX "")
endif()
target_compile_definitions(dsound PRIVATE ${DSOAL_DEFS})
target_include_directories(dsound PRIVATE ${DSOAL_INC})
target_compile_options(dsound PRIVATE ${DSOAL_FLAGS})
target_link_libraries(dsound PRIVATE ${DSOAL_LIBS})