forked from uNetworking/uWebSockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (64 loc) · 2.23 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
cmake_minimum_required(VERSION 3.0)
project(uWS)
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Default to shared libs if not set
if (NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
if (BUILD_SHARED_LIBS)
message("-- building shared libs")
else()
message("-- building static libs")
endif()
# REVISIT: maybe should default to Debug, and give installation
# notes for building release?
# Default to release build if not set
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
message("-- build type: ${CMAKE_BUILD_TYPE}")
# Build uWebSockets Library
add_library(uWS
src/Extensions.cpp
src/Group.cpp
src/Networking.cpp
src/Hub.cpp
src/Node.cpp
src/WebSocket.cpp
src/HTTPSocket.cpp
src/Socket.cpp
src/Epoll.cpp)
target_compile_options(uWS PUBLIC -std=c++11)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("-- stripping library")
target_compile_options(uWS PUBLIC -s)
endif()
if (USE_LTO)
message("-- using LTO")
# CMake 3.9 supports "INTERPROCEDURAL_OPTIMIZATION" property, but set it
# manually for now
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
# set_target_properties(uWS PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
target_compile_options(uWS PUBLIC -flto)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# TODO: clang doesn't support this flag?
target_compile_options(uWS PUBLIC -fno-fat-lto-objects)
endif()
endif()
# Build Test Binary
find_package(OpenSSL REQUIRED)
find_package(Threads REQUIRED)
find_package(Z REQUIRED)
find_package(Libuv REQUIRED)
add_executable(testsBin tests/main.cpp)
target_include_directories(testsBin PRIVATE src/)
target_link_libraries(testsBin PRIVATE uWS)
target_link_libraries(testsBin PRIVATE ${OPENSSL_LIBRARIES})
target_link_libraries(testsBin PRIVATE ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(testsBin PRIVATE ${Z_LIBRARY})
target_link_libraries(testsBin PRIVATE ${LIBUV_LIBRARIES})
# "make install" support
# XXX: the old Makefile would try $PREFIX/lib64 first if present, do we want
# to preserve that behavior?
install(TARGETS uWS DESTINATION lib)
install(DIRECTORY src/ DESTINATION include/uWS FILES_MATCHING PATTERN "*.h")