Back
Close

Introduction to cmake

raphaelmeyer
3,593 views

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
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants