Introduction to cmake

raphaelmeyer
29.5K 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 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
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content