Introduction to cmake
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Time Machine Executable
Now let us put everything together to build the time machine application.
Exercise 6
Add the following components to the project:
-
Library
time_machine:- Alias target:
time_machine::time_machine - Sources:
src/time_machine.ccsrc/time_machine.h
- Private dependencies:
time_machine::flux_capacitortime_machine::time_display
- Alias target:
-
Executable
time_machine_app:- Alias target:
time_machine::application - Sources:
src/main.cc
- Private dependencies:
time_machine::time_machineproject::settings
- Alias target:
-
Tests
time_machine-tests:- Alias target:
tests::time_machine - Run target:
run-time_machine-tests - Private dependencies:
time_machine::time_machinecatchorg::catch2project::settings
- Alias target:
Folder structure
[project]/
+--- CMakeLists.txt
+--- time_machine/
| +--- CMakeLists.txt
| +--- src/
| | +--- main.cc
| | +--- time_machine.cc
| | +--- time_machine.h
| +--- tests/
| | +--- CMakeLists.txt
| +--- time_machine.cc
+--- ...
Run CMake
1
2
3
4
5
6
7
8
9
10
11
# [project]/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project("TimeMachine" VERSION 1.0.2 LANGUAGES CXX)
add_subdirectory(vendor)
add_subdirectory(time_travel_interface)
add_subdirectory(flux_capacitor)
add_subdirectory(time_display)
add_subdirectory(settings)
Press desired key combination and then press ENTER.
1
# [project]/time_machine/CMakeLists.txt
Press desired key combination and then press ENTER.
1
# [project]/time_machine/tests/CMakeLists.txt
Press desired key combination and then press ENTER.
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content