|
1 | 1 | cmake_minimum_required(VERSION 3.12) |
2 | | -project(coro_http_server CXX) |
3 | 2 | set(CMAKE_CXX_STANDARD 20) |
| 3 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
4 | 4 |
|
| 5 | +project(coro_http_server CXX) |
| 6 | +set(BIN_OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/../bin) |
| 7 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR}) |
| 8 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR}) |
| 9 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR}) |
| 10 | +foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) |
| 11 | + string(TOUPPER ${cfg} cfg_upper) |
| 12 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${cfg_upper} ${BIN_OUTPUT_DIR}) |
| 13 | + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${cfg_upper} ${BIN_OUTPUT_DIR}) |
| 14 | + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${cfg_upper} ${BIN_OUTPUT_DIR}) |
| 15 | +endforeach() |
5 | 16 | find_package(PkgConfig REQUIRED) |
6 | 17 | pkg_check_modules(LIBURING REQUIRED liburing) |
7 | 18 |
|
8 | | -file(GLOB SRCS *.cpp) |
9 | | -file(GLOB HDRS *.h) |
10 | | - |
11 | | -add_library(coro_http_server ${SRCS}) |
12 | | -target_include_directories(coro_http_server PUBLIC |
13 | | - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 19 | +option(ENABLE_ASAN "Enable AddressSanitizer" OFF) |
| 20 | +add_library(coro_http_server |
| 21 | + src/io_uring.cpp |
| 22 | + src/read_iterator.cpp |
| 23 | + src/http_error.cpp |
| 24 | + src/trie.cpp |
| 25 | + src/server.cpp |
| 26 | +) |
| 27 | +add_library(coro_http_server::coro_http_server ALIAS coro_http_server) |
| 28 | +target_compile_options(coro_http_server PUBLIC -fmodules) |
| 29 | +target_include_directories(coro_http_server PUBLIC |
| 30 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
14 | 31 | $<INSTALL_INTERFACE:include> |
15 | 32 | ${LIBURING_INCLUDE_DIRS} |
16 | 33 | ) |
| 34 | +target_compile_options(coro_http_server PRIVATE -O3 -g -fno-omit-frame-pointer) |
| 35 | +if (ENABLE_ASAN) |
| 36 | + target_compile_options(coro_http_server PRIVATE -fsanitize=address) |
| 37 | + target_link_options(coro_http_server PUBLIC -fsanitize=address) |
| 38 | +endif() |
17 | 39 | target_link_libraries(coro_http_server PUBLIC ${LIBURING_LIBRARIES}) |
18 | 40 |
|
19 | 41 | include(GNUInstallDirs) |
20 | 42 | install(TARGETS coro_http_server EXPORT MyServerConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
21 | 43 | install(EXPORT MyServerConfig FILE coro_http_serverConfig.cmake NAMESPACE coro_http_server:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/coro_http_server) |
22 | | -install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 44 | +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
0 commit comments