-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
104 lines (85 loc) · 3.19 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
cmake_minimum_required (VERSION 2.6)
project (mongoose)
option (MAIN "Compile the main" OFF)
option (EXAMPLES "Compile examples" ON)
option (HAS_JSON11 "Enables support for Json11 (https://github.com/dropbox/json11)" OFF)
option (ENABLE_REGEX_URL "Enable url regex matching dispatcher" OFF)
set (JSON11_DIR "${PROJECT_SOURCE_DIR}/../json11" CACHE STRING "Json11 (https://github.com/dropbox/json11) directory")
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif ()
else ()
set (CMAKE_CXX_STANDARD 11)
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
include(GetVersionFromGitTag)
if (ENABLE_REGEX_URL)
add_definitions("-DENABLE_REGEX_URL")
SET (CMAKE_CXX_FLAGS "-std=c++11")
endif (ENABLE_REGEX_URL)
include_directories(${CMAKE_BINARY_DIR})
include_directories ("${PROJECT_SOURCE_DIR}/lib")
include_directories ("vendor/mongoose")
include_directories ("vendor/libyuarel")
add_definitions("-DMG_ENABLE_CALLBACK_USERDATA")
add_definitions("-DMG_ENABLE_HTTP_STREAMING_MULTIPART")
add_definitions("-DMG_ENABLE_THREADSAFE_MBUF")
add_definitions("-DMG_ENABLE_HTTP_WEBSOCKET=0")
find_package (Threads)
set(HEADERS
lib/Utils.h
lib/Controller.h
lib/Request.h
lib/AbstractRequestCoprocessor.h
lib/Response.h
lib/Server.h
lib/Session.h
lib/Sessions.h
)
set(SOURCES
lib/Utils.cpp
lib/Controller.cpp
lib/Request.cpp
lib/Response.cpp
lib/Server.cpp
lib/Session.cpp
lib/Sessions.cpp
vendor/mongoose/mongoose.c
vendor/libyuarel/yuarel.c
)
# Adding sockets for Win32
if (WIN32)
set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32)
else(WIN32)
set (EXTRA_LIBS ${EXTRA_LIBS} dl)
endif (WIN32)
# Compiling library
add_library (mongoose ${SOURCES})
target_link_libraries (mongoose ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT})
if (HAS_JSON11)
add_definitions("-DHAS_JSON11")
include_directories ("${JSON11_DIR}/include/")
link_directories("${JSON11_DIR}/lib/")
target_link_libraries (mongoose json11)
endif (HAS_JSON11)
# Compiling tests
if (EXAMPLES)
add_executable (basic_auth examples/basic_auth.cpp)
target_link_libraries (basic_auth mongoose)
add_executable (examples examples/examples.cpp)
target_link_libraries (examples mongoose)
if (HAS_JSON11)
target_link_libraries (examples json11)
endif (HAS_JSON11)
endif (EXAMPLES)
# install
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/mongoose-cpp/" CACHE PATH "The directory the headers are installed in")
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/" CACHE PATH "The directory the library is installed in")
install (FILES ${HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}")
install (TARGETS mongoose DESTINATION lib EXPORT mongoose-targets)
install (EXPORT mongoose-targets DESTINATION "lib/cmake/mongoose" FILE MongooseTargets.cmake)
configure_file(MongooseConfig.cmake.in MongooseConfig.cmake @ONLY)
configure_file("version.h.in" "version.h" @ONLY)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/MongooseConfig.cmake DESTINATION "lib/cmake/mongoose")
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h DESTINATION "${INCLUDE_INSTALL_DIR}")