Introduction to cmake

raphaelmeyer
1,646 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

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
  • 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
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
# [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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content