-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
102 lines (82 loc) · 1.91 KB
/
CMakeLists.txt
File metadata and controls
102 lines (82 loc) · 1.91 KB
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
cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 20)
if(LINUX)
set(CMAKE_CXX_COMPILER "clang++")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(WebCore)
set(WEBCORE_VERSION_MAJOR 0)
set(WEBCORE_VERSION_MINOR 1)
set(SOURCES
src/HttpStatus.cpp
src/HttpMethod.cpp
src/Router.cpp
src/Request.cpp
src/Response.cpp
src/App.cpp
src/Logger.cpp
)
set(HEADERS
include/WebCore/WebCore.h
include/WebCore/HttpStatus.h
include/WebCore/HttpMethod.h
include/WebCore/HttpHeader.h
include/WebCore/Router.h
include/WebCore/Request.h
include/WebCore/Response.h
include/WebCore/App.h
include/WebCore/Utils/Logger.h
)
set(TESTS
tests/Router_test.cpp
)
set(EXAMPLE
example/main.cpp
example/App.cpp
)
add_library(WebCore ${SOURCES} ${HEADERS})
target_include_directories(WebCore
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_precompile_headers(WebCore
PRIVATE
src/Common.h
)
if(WIN32)
target_link_libraries(WebCore
PRIVATE
wsock32
ws2_32
)
endif()
target_compile_options(WebCore
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
enable_testing()
foreach(test_src ${TESTS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} WebCore)
add_test(
NAME
${test_name}
COMMAND
${test_name}
)
endforeach()
get_filename_component(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}" ABSOLUTE)
add_executable(example_WebCore ${EXAMPLE})
target_link_libraries(example_WebCore
PRIVATE
WebCore
)
target_compile_definitions(example_WebCore
PRIVATE
PROJECT_ROOT_DIR="${PROJECT_ROOT_DIR}"
)