generated from bmstu-iu8-cpp-sem-3/lab-09-producer-consumer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (97 loc) · 3.31 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_DOCS "Build documentation" OFF)
option(BUILD_COVERAGE "Build code coverage" OFF)
set(
HUNTER_CACHE_SERVERS
"https://github.com/bmstu-iu8-cpp-sem-3/hunter-cache"
CACHE STRING "Default cache server"
)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.278.tar.gz"
SHA1 "35fa55bc1dfcf9f4d7264f8bb26cd1759ce1ae07"
)
# TODO: rename project and delete this comment
project(crawler)
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-command-line-argument")
string(APPEND CMAKE_CXX_FLAGS " -Wshadow -Wnon-virtual-dtor")
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
hunter_add_package(gumbo)
find_package(gumbo CONFIG REQUIRED)
hunter_add_package(Boost COMPONENTS program_options log filesystem system thread)
find_package(Boost COMPONENTS program_options log log_setup filesystem system thread CONFIG REQUIRED)
hunter_add_package(OpenSSL)
find_package(OpenSSL REQUIRED)
add_library(${PROJECT_NAME} STATIC
sources/page_queue.cc
sources/url_queue.cc
sources/html_parser.cc
sources/downloader.cc
sources/settings.cc
sources/log_setup.cc
sources/image_url_queue.cc)
add_executable(demo demo/demo.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
set(LIBS Boost::boost
${Boost_BEAST_LIBRARY}
${Boost_LOG_SETUP_LIBRARY}
${Boost_LOG_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY}
Boost::program_options
gumbo::gumbo
OpenSSL::SSL
OpenSSL::Crypto
)
target_link_libraries(${PROJECT_NAME} ${LIBS})
target_link_libraries(demo ${PROJECT_NAME} ${LIBS})
if(BUILD_TESTS)
add_executable(tests
# TODO: enum your files and delete this comment
${CMAKE_CURRENT_SOURCE_DIR}/tests/test.cpp
)
target_link_libraries(tests ${PROJECT_NAME} GTest::gtest_main)
enable_testing()
add_test(NAME unit_tests COMMAND tests)
endif()
if(BUILD_COVERAGE)
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/coverage/cmake")
find_package(codecov)
string(APPEND CMAKE_CXX_FLAGS " --coverage")
add_coverage(${PROJECT_NAME})
add_coverage(tests)
coverage_evaluate()
endif()
if(BUILD_DOCS)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/_docs)
set(DOXYGEN_EXAMPLE_PATH examples)
set(DOXYGEN_GENERATE_HTML NO)
set(DOXYGEN_GENERATE_MAN YES)
find_package(Doxygen)
doxygen_add_docs(docs include)
install(DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY}/man DESTINATION share)
# add_dependencies(install docs) need to call target docs before install or package
endif()
include(CPackConfig.cmake)
install(TARGETS ${PROJECT_NAME} demo
EXPORT "${PROJECT_NAME}-targets"
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
install(EXPORT "${PROJECT_NAME}-targets"
NAMESPACE "${PROJECT_NAME}::"
DESTINATION "lib/cmake"
)