-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathCMakeLists.txt
59 lines (47 loc) · 1.52 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
cmake_minimum_required(VERSION 3.10)
# Project name
project(WebUILibrary)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Variables for library names, source files, etc.
set(WEBUI_OUT_LIB_NAME "webui-2")
# Conditional compilation for TLS
option(WEBUI_USE_TLS "Enable TLS support" OFF)
if(WEBUI_USE_TLS)
find_package(OpenSSL REQUIRED)
set(WEBUI_OUT_LIB_NAME "webui-2-secure")
endif()
# Source files (already filled)
set(SOURCE_FILES
src/civetweb/civetweb.c
src/webui.c
)
# Library targets
add_library(webui ${SOURCE_FILES})
target_include_directories(webui PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_compile_definitions(webui PUBLIC NDEBUG NO_CACHING NO_CGI USE_WEBSOCKET)
if(BUILD_SHARED_LIBS AND WIN32)
target_compile_definitions(webui PRIVATE CIVETWEB_DLL_EXPORTS PUBLIC CIVETWEB_DLL_IMPORTS)
endif()
if(WEBUI_USE_TLS)
target_compile_definitions(webui PUBLIC WEBUI_TLS NO_SSL_DL OPENSSL_API_1_1)
target_link_libraries(webui PRIVATE OpenSSL::SSL OpenSSL::Crypto)
else()
target_compile_definitions(webui PUBLIC NO_SSL)
endif()
set_target_properties(webui PROPERTIES
OUTPUT_NAME ${WEBUI_OUT_LIB_NAME}
PREFIX "")
# Install headers
install(FILES include/webui.h include/webui.hpp DESTINATION include)
# Install targets
install(TARGETS webui
EXPORT webui
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
install(EXPORT webui
FILE webui-config.cmake
NAMESPACE webui::
DESTINATION share/webui
)