This repository has been archived by the owner on May 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
175 lines (149 loc) · 5.33 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
#
# CMakeLists.txt
#
# Copyright (c) 2011-2018 MLBA-Team
# All rights reserved.
#
# @LICENSE_HEADER_START@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# @LICENSE_HEADER_END@
#
cmake_minimum_required(VERSION 2.8)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckSymbolExists)
# start new subproject
project(xdispatch)
include(package/version.cmake)
# ctest config
option(BUILD_XDISPATCH_TESTS "Enable to build the xdispatch test suite" OFF)
include(CTest)
enable_testing()
# check if mz_tools is available
if(NOT HAS_MZ_GLOBAL)
set(MZ_TOOLS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build")
include(build/global.cmake)
# We need to ouput everything into the same directory
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/ CACHE PATH "Library output path")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/ CACHE PATH "Executable output path")
message("-- Setting binary output path: ${CMAKE_BINARY_DIR}/bin/")
endif()
# is the used compiler clang? if so we need blocks support
if(MZ_IS_CLANG AND NOT MZ_MACOS)
message("-- linking with the BlocksRuntime")
mz_find_include_library(BlocksRuntime
SYS 0
SRC libblocksruntime libblocksruntime BlocksRuntime
)
mz_add_flag(CLANG -fblocks)
set(LIBS ${LIBS} BlocksRuntime)
endif()
# are we running on mac os and want to build universal binaries?
if(MZ_MACOS)
option(XDISPATCH_UNIVERSAL "Enable to build universal binaries" off)
if( XDISPATCH_UNIVERSAL )
message("-- building universal binaries")
mz_add_flag(GCC -arch i386 -arch x86_64)
endif()
endif()
check_include_files(sys/event.h FOUND_KQUEUE_IMPL)
check_include_files(kqueue/sys/event.h FOUND_LIBKQUEUE_IMPL)
if(FOUND_KQUEUE_IMPL OR FOUND_LIBKQUEUE_IMPL)
option(FORCE_OWN_LIBKQUEUE "Enable to force the use of the shipped libkqueue version" OFF)
else()
option(FORCE_OWN_LIBKQUEUE "Enable to force the use of the shipped libkqueue version" ON)
endif()
check_include_files(pthread_workqueue.h FOUND_PTHREAD_WORKQUEUE_IMPL)
if(FOUND_PTHREAD_WORKQUEUE_IMPL)
option(FORCE_OWN_LIBPTHREAD_WORKQUEUE "Enable to force the use of the shipped libpthread_workqueue version" OFF)
else()
option(FORCE_OWN_LIBPTHREAD_WORKQUEUE "Enable to force the use of the shipped libpthread_workqueue version" ON)
endif()
check_include_files(dispatch/dispatch.h HAVE_NATIVE_DISPATCH_H)
if(HAVE_NATIVE_DISPATCH_H)
option(FORCE_OWN_LIBDISPATCH "Enable to force the use of the shipped libdispatch version" OFF)
else()
option(FORCE_OWN_LIBDISPATCH "Enable to force the use of the shipped libdispatch version" ON)
endif()
# Qt Extension if Qt is available
# new: Qt5 is separated into modules
find_package(Qt5Core)
if( Qt5Core_VERSION )
find_package(Qt5Network)
find_package(Qt5Widgets)
option(XDISPATCH_QT_SUPPORT "Enable to build QtDispatch" ON)
else()
option(XDISPATCH_QT_SUPPORT "Enable to build QtDispatch" OFF)
endif()
if(FORCE_OWN_LIBKQUEUE AND FORCE_OWN_LIBDISPATCH)
option(STATIC_KQUEUE "" ON)
mz_add_definition(MAKE_STATIC=1 STATIC_KQUEUE=1)
mz_add_library(libkqueue libkqueue)
target_include_directories(kqueue
PUBLIC libkqueue/include
)
endif()
# currently there's a bug in mingw causing the
# builtin atomic opts not to work without this
if(MINGW AND MZ_32BIT)
mz_add_flag(GCC -march=i486)
endif()
# we hide all unneeded symbols
if(NOT MZ_WINDOWS)
mz_add_flag(GCC -fvisibility=hidden)
endif()
if(FORCE_OWN_LIBPTHREAD_WORKQUEUE AND FORCE_OWN_LIBDISPATCH)
option(STATIC_WORKQUEUE "" ON)
mz_add_definition(MAKE_STATIC=1 STATIC_WORKQUEUE=1)
mz_add_library(libpthread_workqueue libpthread_workqueue)
target_include_directories(pthread_workqueue
PUBLIC libpthread_workqueue/include
)
endif()
# do we have native dispatch support on this platform?
if(NOT FORCE_OWN_LIBDISPATCH)
message(" >> using system installed libdispatch")
mz_add_definition("HAVE_NATIVE_DISPATCH_H=1")
if(NOT MZ_MACOS AND NOT MZ_IOS) # mac os / ios is currently the only operating system with auto linking
set(LIBS ${LIBS} dispatch)
endif()
else()
mz_add_library(dispatch libdispatch)
set(LIBS ${LIBS} dispatch)
endif()
# the xdispatch target
mz_add_library(xdispatch libxdispatch)
if(XDISPATCH_QT_SUPPORT)
mz_add_library(QtDispatch libqtdispatch)
endif()
# custom test framework for xdispatch
if(BUILD_XDISPATCH_TESTS)
mz_add_executable(tests tests)
endif()
# documentation
option(XDISPATCH_DOCS "Set to add a documentation ('Docs') target" OFF)
if(XDISPATCH_DOCS)
include(docs/docgen.cmake)
endif()
# packaging
if( XDISPATCH_INCLUDE_PACKAGING )
if(MZ_MACOS)
include(package/osx/pkg.cmake)
elseif(MZ_LINUX)
include(package/rpm/rpm.cmake)
include(package/debian/deb.cmake)
include(package/ubuntu/deb.cmake)
else() # Windows ...
include(package/windows/zip.cmake)
endif()
include(CPack)
endif()