forked from stream-labs/lib-datalane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
206 lines (182 loc) · 7.38 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
cmake_minimum_required(VERSION 3.5)
project(lib-datalane VERSION 0.0.1)
# Test if we are a subproject
SET(OPTIONPREFIX "lib-datalane_")
IF(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
SET(OPTIONPREFIX "")
ENDIF()
# Detect Architecture (Bitness)
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
################################################################################
# Settings
################################################################################
# Static or Dynamic?
OPTION(${OPTIONPREFIX}BUILD_STATIC "Build Static Library" ON)
OPTION(${OPTIONPREFIX}BUILD_MODULE "Build Module Library instead of Dynamic Library" OFF)
# Tests
OPTION(${OPTIONPREFIX}BUILD_SAMPLES "Build Samples" OFF)
OPTION(${OPTIONPREFIX}BUILD_TESTS "Build Tests" OFF)
################################################################################
# System & Utilities
################################################################################
# Detect Libary Suffix
IF(WIN32)
SET(libExtension ".dll")
ELSEIF(APPLE)
SET(libExtension ".dylib")
ELSE()
SET(libExtension ".so")
ENDIF()
################################################################################
# Source
################################################################################
SET(PROJECT_SOURCE_PUBLIC
"${PROJECT_SOURCE_DIR}/include/datalane.hpp"
"${PROJECT_SOURCE_DIR}/include/datalane-socket.hpp"
"${PROJECT_SOURCE_DIR}/include/datalane-error.hpp"
)
SET(PROJECT_SOURCE_PRIVATE
"${PROJECT_SOURCE_DIR}/source/datalane.cpp"
"${PROJECT_SOURCE_DIR}/source/datalane-socket.cpp"
"${PROJECT_SOURCE_DIR}/source/datalane-socket-client.hpp"
"${PROJECT_SOURCE_DIR}/source/datalane-socket-client.cpp"
"${PROJECT_SOURCE_DIR}/source/datalane-socket-server.hpp"
"${PROJECT_SOURCE_DIR}/source/datalane-socket-server.cpp"
"${PROJECT_SOURCE_DIR}/source/os/async_op.hpp"
"${PROJECT_SOURCE_DIR}/source/os/async_op.cpp"
"${PROJECT_SOURCE_DIR}/source/os/error.hpp"
"${PROJECT_SOURCE_DIR}/source/os/semaphore.hpp"
"${PROJECT_SOURCE_DIR}/source/os/tags.hpp"
"${PROJECT_SOURCE_DIR}/source/os/waitable.hpp"
)
SET(PROJECT_DATA
"${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/LICENSE"
)
SET(PROJECT_LIBRARIES
)
IF(WIN32)
LIST(APPEND PROJECT_LIBRARIES
advapi32
)
LIST(APPEND PROJECT_SOURCE_PRIVATE
"${PROJECT_SOURCE_DIR}/source/os/windows/async_request.hpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/async_request.cpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/named-pipe.hpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/named-pipe.cpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/overlapped.hpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/overlapped.cpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/semaphore.hpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/semaphore.cpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/utility.hpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/utility.cpp"
"${PROJECT_SOURCE_DIR}/source/os/windows/waitable.cpp"
)
ELSEIF(APPLE)
# MacOSX
LIST(APPEND PROJECT_SOURCE_PRIVATE
)
ELSEIF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# Linux
LIST(APPEND PROJECT_SOURCE_PRIVATE
)
ELSEIF("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
# FreeBSD
LIST(APPEND PROJECT_SOURCE_PRIVATE
)
ENDIF()
# Grouping
source_group("Data Files" FILES $lib-datalane_DATA)
source_group(TREE "${PROJECT_SOURCE_DIR}/source" PREFIX "Source" FILES ${PROJECT_SOURCE_PRIVATE})
source_group(TREE "${PROJECT_SOURCE_DIR}/include" PREFIX "Include" FILES ${PROJECT_SOURCE_PUBLIC})
################################################################################
# Building
################################################################################
# Building
IF(${OPTIONPREFIX}BUILD_STATIC)
ADD_LIBRARY(${PROJECT_NAME} STATIC
${PROJECT_SOURCE_PRIVATE}
${PROJECT_SOURCE_PUBLIC}
)
ELSEIF(${OPTIONPREFIX}BUILD_MODULE)
ADD_LIBRARY(${PROJECT_NAME} MODULE
${PROJECT_SOURCE_PRIVATE}
${PROJECT_SOURCE_PUBLIC}
)
ELSE()
ADD_LIBRARY(${PROJECT_NAME} SHARED
${PROJECT_SOURCE_PRIVATE}
${PROJECT_SOURCE_PUBLIC}
)
ENDIF()
IF(WIN32)
# Windows
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
# windows.h
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOGPICAPMASKS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOVIRTUALKEYCODES)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOWINMESSAGES)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOWINSTYLES)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSYSMETRICS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMENUS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOICONS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOKEYSTATES)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSYSCOMMANDS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NORASTEROPS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSHOWWINDOW)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOATOM)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOCLIPBOARD)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOCOLOR)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOCTLMGR)
target_compile_definitions(${PROJECT_NAME} PRIVATE NODRAWTEXT)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOGDI)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOKERNEL)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOUSER)
target_compile_definitions(${PROJECT_NAME} PRIVATE NONLS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMB)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMEMMGR)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMETAFILE)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMSG)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOOPENFILE)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSCROLL)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSERVICE)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOSOUND)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOTEXTMETRIC)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOWH)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOWINOFFSETS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOCOMM)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOKANJI)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOHELP)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOPROFILER)
target_compile_definitions(${PROJECT_NAME} PRIVATE NODEFERWINDOWPOS)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMCX)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOIME)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMDI)
target_compile_definitions(${PROJECT_NAME} PRIVATE NOINOUT)
ENDIF()
# Includes
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
PRIVATE source
PUBLIC include
)
# Directories
LINK_DIRECTORIES(
)
# Linking
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
${PROJECT_LIBRARIES}
)
################################################################################
# Samples
################################################################################
IF(${OPTIONPREFIX}BUILD_SAMPLES)
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/samples)
ENDIF(${OPTIONPREFIX}BUILD_SAMPLES)
################################################################################
# Tests
################################################################################
IF(${OPTIONPREFIX}BUILD_TESTS)
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/tests)
ENDIF(${OPTIONPREFIX}BUILD_TESTS)