-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
112 lines (96 loc) · 3.55 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
project(swear_paper_proj)
cmake_minimum_required(VERSION 3.24)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_link_options(-fuse-ld=mold)
include(cmake/conan.cmake)
include(cmake/cpplint.cmake)
include(cmake/gcov.cmake)
include(cmake/ccache.cmake)
set(_FLAGS -Wall -Wextra -Wpedantic -Werror -O0 -Wfatal-errors)
find_package(fmt 9.1.0 REQUIRED)
find_package(Boost 1.71.0 REQUIRED COMPONENTS program_options)
find_package(CURL 7.67.0 REQUIRED)
find_package(OpenCV 4.1.2 REQUIRED)
find_package(nlohmann_json 3.11.2 REQUIRED)
find_package(spdlog 1.10.0 REQUIRED)
add_library(core STATIC
src/lib/include/interfaces/configuration_interface.hpp
src/lib/include/interfaces/reddit_interface.hpp
src/lib/include/interfaces/downloader_interface.hpp
src/lib/include/image_location.hpp
src/lib/include/cache_or_download.hpp
src/lib/include/image_size.hpp
src/lib/include/fmt_optional.hpp
src/lib/include/downloader.hpp
src/lib/include/environment_configuration.hpp
src/lib/environment_configuration.cpp
src/lib/downloader.cpp
src/lib/cache_or_download.cpp
src/lib/include/earthporn.hpp
src/lib/earthporn.cpp
src/lib/include/image.hpp
src/lib/image.cpp
)
target_include_directories(core PUBLIC src/lib/include)
target_link_libraries(core PUBLIC
fmt::fmt
Boost::program_options
CURL::libcurl
opencv::opencv_core
opencv::opencv_imgcodecs
nlohmann_json::nlohmann_json
spdlog::spdlog)
target_compile_features(core PUBLIC cxx_std_17)
target_compile_options(core PRIVATE ${_FLAGS})
target_precompile_headers(core PUBLIC
src/lib/include/interfaces/configuration_interface.hpp
src/lib/include/interfaces/reddit_interface.hpp
src/lib/include/interfaces/downloader_interface.hpp
src/lib/include/image_location.hpp
src/lib/include/cache_or_download.hpp
src/lib/include/image_size.hpp
src/lib/include/fmt_optional.hpp
src/lib/include/downloader.hpp
src/lib/include/environment_configuration.hpp
src/lib/include/earthporn.hpp
src/lib/include/image.hpp
)
add_executable(swear_paper src/main.cpp)
target_link_libraries(swear_paper PRIVATE core)
target_compile_options(swear_paper PRIVATE ${_FLAGS})
find_package(GTest REQUIRED)
add_executable(swear_paper_test
test/expected_reply.hpp
test/earthporn_json_parse_test.cpp
test/downloader_test.cpp
test/environment_configuration_test.cpp
test/cache_or_download_test.cpp
)
target_compile_options(swear_paper_test PRIVATE ${_FLAGS})
target_link_libraries(swear_paper_test PRIVATE core GTest::gtest_main GTest::gmock)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(swear_paper_test PRIVATE -Wno-unused-but-set-variable)
target_compile_options(swear_paper PRIVATE -fsanitize=undefined -fsanitize=address -Wno-unused-function)
target_link_options(swear_paper PRIVATE -fsanitize=undefined -fsanitize=address)
endif()
option(LINT "cpplint" OFF)
if(${LINT})
message(STATUS "Enabling cpplint")
add_style_check_target(core)
endif()
option(ANALYSE "clang-tidy" OFF)
if(${ANALYSE})
message(STATUS "Enabling clang-tidy")
include(cmake/clang-tidy.cmake)
endif()
option(COVERAGE "gcov html report" OFF)
if(${COVERAGE})
message(STATUS "Enabling coverage")
target_compile_options(core PRIVATE ${_FLAGS} --coverage)
target_link_libraries(core PRIVATE gcov)
setup_target_for_coverage_gcovr_html(NAME core_coverage EXECUTABLE swear_paper_test)
endif()