Introduction to cmake
raphaelmeyer
27.2K views
Time Display Library
Now, we are going to add the time display library to project, including the tests.
Exercise 5
Add the time display library to the project in the same way as the flux capacitor library. Include the tests as well.
-
Library
time_display
:- Alias target:
time_machine::time_display
- Private dependencies:
time_machine::time_travel
project::settings
- Alias target:
-
Tests
time_display-tests
:- Alias target:
tests::time_display
- Run target:
run-time_display-tests
- Private dependencies:
time_machine::time_display
time_machine::time_travel
catchorg::catch2
project::settings
- Alias target:
Folder structure
[project]/
+--- CMakeLists.txt
+--- time_display/
| +--- CMakeLists.txt
| +--- include/
| | +--- time_display/
| | +--- display.h
| +--- src/
| | +--- colors.cc
| | +--- colors.h
| | +--- display.cc
| | +--- numbers.cc
| | +--- numbers.h
| +--- tests/
| +--- CMakeLists.txt
| +--- colors.cc
| +--- numbers.cc
| +--- time_display.cc
|
+--- ...
Run CMake
1
2
3
4
5
6
7
8
9
10
# [project]/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project("TimeMachine" VERSION 1.0.2 LANGUAGES CXX)
add_subdirectory(time_travel_interface)
add_subdirectory(flux_capacitor)
add_subdirectory(settings)
add_subdirectory(vendor)
1
# [project]/time_display/CMakeLists.txt
1
# [project]/time_display/tests/CMakeLists.txt
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Suggested playgrounds