Introduction to cmake

raphaelmeyer
2,532 views
undefined

Open Source Your Knowledge, Become a Contributor

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

Create Content

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.cc
      • src/time_machine.h
    • Private dependencies:
      • time_machine::flux_capacitor
      • time_machine::time_display
  • Executable time_machine_app:

    • Alias target: time_machine::application
    • Sources:
      • src/main.cc
    • Private dependencies:
      • time_machine::time_machine
      • project::settings
  • Tests time_machine-tests:

    • Alias target: tests::time_machine
    • Run target: run-time_machine-tests
    • Private dependencies:
      • time_machine::time_machine
      • catchorg::catch2
      • project::settings
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
# [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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content