-
Notifications
You must be signed in to change notification settings - Fork 51
/
CMakeLists.txt
159 lines (135 loc) · 4.3 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
cmake_minimum_required(VERSION 3.0.2)
project(DSOAL C)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckTypeSize)
include(CheckIncludeFile)
include(GNUInstallDirs)
set(VERSION 0.9)
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_TEXT
LICENSE
README.md)
set(DSOAL_OBJS
buffer.c
capture.c
dsound8.c
dsound_main.c
dsound_private.h
duplex.c
eax.c
eax.h
eax3.h
eax4.h
eax-presets.h
primary.c
propset.c
voiceman.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)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
add_library(dsound SHARED ${DSOAL_OBJS} msvc64.def)
else()
add_library(dsound SHARED ${DSOAL_OBJS} msvc.def)
endif()
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})
install(TARGETS dsound
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(EXISTS "${DSOAL_BINARY_DIR}/dsoal-aldrv.dll")
install(FILES
"${DSOAL_BINARY_DIR}/dsoal-aldrv.dll"
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
target_sources(dsound PRIVATE ${DSOAL_TEXT})
install(FILES ${DSOAL_TEXT} TYPE DATA)
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_VENDOR "Chris Robinson")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_OUTPUT_FILE_PREFIX packages)
include(CPack)