-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCMakeLists.txt
59 lines (43 loc) · 1.68 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.12)
project(service_template CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(DownloadUserver)
find_package(userver COMPONENTS core QUIET)
if(NOT userver_FOUND)
# Tries TRY_DIR first, falls back to downloading userver from GitHub using CPM.
download_userver(TRY_DIR third_party/userver)
endif()
userver_setup_environment()
# Common sources
add_library(${PROJECT_NAME}_objs OBJECT
src/hello.hpp
src/hello.cpp
)
target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver::core)
# The Service
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_objs)
# Unit Tests
add_executable(${PROJECT_NAME}_unittest
src/hello_test.cpp
)
target_link_libraries(${PROJECT_NAME}_unittest PRIVATE ${PROJECT_NAME}_objs userver::utest)
add_google_tests(${PROJECT_NAME}_unittest)
# Benchmarks
add_executable(${PROJECT_NAME}_benchmark
src/hello_benchmark.cpp
)
target_link_libraries(${PROJECT_NAME}_benchmark PRIVATE ${PROJECT_NAME}_objs userver::ubench)
add_google_benchmark_tests(${PROJECT_NAME}_benchmark)
# Functional testing
userver_testsuite_add_simple()
# Install
include(GNUInstallDirs)
if(DEFINED ENV{PREFIX})
message(STATUS "Set install prefix: $ENV{PREFIX}")
file(TO_CMAKE_PATH "$ENV{PREFIX}" PREFIX_PATH)
set(CMAKE_INSTALL_PREFIX "${PREFIX_PATH}")
endif()
file(GLOB CONFIGS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.yaml ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.json)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PROJECT_NAME})
install(FILES ${CONFIGS_FILES} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME} COMPONENT ${PROJECT_NAME})