File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 11include (FetchContent)
22
3+
34FetchContent_Declare(
45 spdlog
56 URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
@@ -8,9 +9,17 @@ FetchContent_Declare(
89
910FetchContent_MakeAvailable(spdlog)
1011
11-
1212add_executable (${PROJECT_NAME} _app main.cpp)
13- target_link_libraries (${PROJECT_NAME} _app PRIVATE ${PROJECT_NAME} ::library)
13+
14+ target_link_libraries (${PROJECT_NAME} _app
15+ PRIVATE ${PROJECT_NAME} ::library spdlog::spdlog
16+ )
17+
18+ # mark spdlog headers as system includes to avoid warnings (-Werror)
19+ get_target_property (_spdlog_includes spdlog::spdlog INTERFACE_INCLUDE_DIRECTORIES )
20+ target_include_directories (${PROJECT_NAME} _app
21+ SYSTEM PRIVATE ${_spdlog_includes}
22+ )
1423
1524enable_strict_warnings(${PROJECT_NAME} _app)
1625enable_sanitizers(${PROJECT_NAME} _app)
Original file line number Diff line number Diff line change 1+ #include < spdlog/sinks/basic_file_sink.h>
2+ #include < spdlog/sinks/stdout_color_sinks.h>
3+ #include < spdlog/spdlog.h>
4+
15#include < iostream>
26
37#include " modern_cpp/library.hpp"
48
59int main () {
10+ auto console = spdlog::stdout_color_mt (" console" );
11+ spdlog::set_level (spdlog::level::debug);
12+
613 const int left = 10 ;
714 const int right = 4 ;
815
9- std::cout << " Add: " << modern_cpp::add (left, right) << ' \n ' ;
10- std::cout << " Subtract: " << modern_cpp::subtract (left, right) << ' \n ' ;
16+ console->info (" Calling add({}, {})" , left, right);
17+ const int sum = modern_cpp::add (left, right);
18+ console->info (" Result of add: {}" , sum);
19+
20+ console->info (" Calling subtract({}, {})" , left, right);
21+ const int diff = modern_cpp::subtract (left, right);
22+ console->info (" Result of subtract: {}" , diff);
1123
1224 return 0 ;
1325}
You can’t perform that action at this time.
0 commit comments