Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
63 lines (51 loc) · 2.65 KB
/
Copy pathCMakeLists.txt
File metadata and controls
63 lines (51 loc) · 2.65 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
cmake_minimum_required(VERSION 3.16)
project(cpphttp VERSION 1.0.0 LANGUAGES CXX)
# ── C++17 ─────────────────────────────────────────────────────────────────────
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# ── Compiler warnings ─────────────────────────────────────────────────────────
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Wpedantic -Wshadow -Wno-unused-parameter)
endif()
# ── Library ───────────────────────────────────────────────────────────────────
add_library(cpphttp
src/server.cpp
src/request.cpp
src/response.cpp
src/router.cpp
src/logger.cpp
)
target_include_directories(cpphttp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# pthreads for std::thread
find_package(Threads REQUIRED)
target_link_libraries(cpphttp PUBLIC Threads::Threads)
# ── Examples ──────────────────────────────────────────────────────────────────
option(BUILD_EXAMPLES "Build example binaries" ON)
if(BUILD_EXAMPLES)
add_executable(hello_world examples/hello_world.cpp)
target_link_libraries(hello_world PRIVATE cpphttp)
add_executable(todo_api examples/todo_api.cpp)
target_link_libraries(todo_api PRIVATE cpphttp)
add_executable(rate_limited_api examples/rate_limited_api.cpp)
target_link_libraries(rate_limited_api PRIVATE cpphttp)
endif()
# ── Tests (optional) ──────────────────────────────────────────────────────────
option(BUILD_TESTS "Build tests" OFF)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# ── Install ───────────────────────────────────────────────────────────────────
install(TARGETS cpphttp EXPORT cpphttpTargets)
install(DIRECTORY include/ DESTINATION include)
install(EXPORT cpphttpTargets
FILE cpphttpTargets.cmake
NAMESPACE cpphttp::
DESTINATION lib/cmake/cpphttp
)