-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
126 lines (113 loc) · 4.85 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
cmake_minimum_required(VERSION 3.5)
project(naquid C CXX)
# global compile options
set(DEBUG false CACHE BOOL "do debug build")
set(CHROMIUM_VERSION "63.0.3222.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DHAVE_PTHREAD -DDISABLE_HISTOGRAM")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -DOPENSSL_NO_ASM -DOSATOMIC_USE_INLINED=1 -DPB_NO_PACKED_STRUCTS")
include_directories(src src/chromium src/chromium/third_party/icu/source/common ext ext/cares)
include_directories(SYSTEM src/chromium/third_party/protobuf/src src/chromium/third_party/boringssl/src/include ext/cares/src)
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -DDEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -DDEBUG")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -DNDEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -DNDEBUG")
endif()
# srcs
set(lib_src
./src/nq.cpp
./src/basis/endian.cpp
./src/basis/logger.cpp
./src/basis/timespec.cpp
./src/core/nq_alarm.cpp
./src/core/nq_async_resolver.cpp
./src/core/nq_at_exit.cpp
./src/core/nq_boxer.cpp
./src/core/nq_client.cpp
./src/core/nq_client_loop.cpp
./src/core/nq_client_session.cpp
./src/core/nq_config.cpp
./src/core/nq_dispatcher.cpp
./src/core/nq_loop.cpp
./src/core/nq_network_helper.cpp
./src/core/nq_packet_reader.cpp
./src/core/nq_packet_writer.cpp
./src/core/nq_proof_verifier.cpp
./src/core/nq_server.cpp
./src/core/nq_server_loop.cpp
./src/core/nq_server_session.cpp
./src/core/nq_session.cpp
./src/core/nq_stream.cpp
./src/core/nq_worker.cpp
./src/core/compat/nq_file_util.cpp
./src/core/compat/nq_quic_socket_utils.cpp
./src/core/compat/nq_ref_counted.cpp
./src/core/compat/nq_spdy_protocol.cpp
./src/core/compat/nq_string_util.cpp
./src/core/compat/nq_url_canon_icu.cpp
./src/core/platform/nq_jni_android.cpp
./src/core/platform/nq_reachability.cpp
./src/core/platform/nq_reachability_android.cpp
)
set(lib_mm_src
./src/core/compat/nq_foundation_util.mm
./src/core/platform/nq_reachability_mac.mm
)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/net.cmake)
# platforms
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/common.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/mac.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/android.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/linux.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/win.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/fuchsia.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/platform/posix.cmake)
# third party srcs
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/third_party/zlib.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/third_party/ssl.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/third_party/pb.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/deps/third_party/cares.cmake)
# setup group specific compiler flags
set_source_files_properties(${cares_src} PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H -D_GNU_SOURCE")
# define common sources
set(src ${lib_src} ${net_src} ${common_src} ${zlib_src} ${ssl_src} ${pb_src} ${cares_src})
# target settings
if (IOS OR NQ_OSX_BUNDLE OR NQ_OSX)
find_library(core_foundation CoreFoundation)
find_library(cocoa Cocoa)
find_library(iokit IOKit)
find_library(security Security)
find_library(system_configuration SystemConfiguration)
set(nqsrc ${src} ${lib_mm_src} ${mac_src})
include_directories(ext/cares/config/darwin)
if (IOS)
# workaround for problem detailed in https://karp.id.au/a/2015/09/15/xcode-7s-new-linker-rules/
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=7.0 -Wno-nullability-completeness -D__ENABLE_KQUEUE__")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -miphoneos-version-min=7.0 -Wno-nullability-completeness")
add_library(nq STATIC ${nqsrc})
target_link_libraries(nq ${core_foundation} ${iokit} ${security} ${system_configuration})
elseif (NQ_OSX_BUNDLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ENABLE_KQUEUE__")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bundle")
add_executable(nq MACOSX_BUNDLE ${nqsrc})
target_link_libraries(nq ${core_foundation} ${cocoa} ${iokit} ${security} ${system_configuration})
elseif (NQ_OSX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ENABLE_KQUEUE__")
add_library(nq STATIC ${nqsrc})
target_link_libraries(nq ${core_foundation} ${cocoa} ${iokit} ${security} ${system_configuration})
endif()
elseif (ANDROID)
include_directories(ext/cares/config/linux)
set(nqsrc ${src} ${android_src})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ENABLE_EPOLL__")
add_library(nq SHARED ${nqsrc})
target_link_libraries(nq "-lc++_static -llog")
elseif (WINDOWS)
messsage(FATAL_ERROR, "TODO(iyatomi): add windows build instruction")
elseif (NQ_LINUX)
include_directories(ext/cares/config/linux)
set(nqsrc ${src} ${linux_src})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ENABLE_EPOLL__")
add_library(nq STATIC ${nqsrc})
endif ()