Skip to content

Chapter 1 Demo

David Zemon edited this page Jul 6, 2018 · 5 revisions

Introduction

For a brief introduction to CMake, let's create a project with the following goals:

  1. Build a library, upper which takes in a string and returns the uppercase version. Source for this library should be in its own folder.
  2. Build a second library, useless, which concatenates a hardcoded string to an input parameter and then uses upper to convert the result to all uppercase characters prior to returning the result. Source for this library should be in its own folder.
  3. The extra string in useless should be stored in its own source file, therefore showcasing multiple source files for a single target
  4. Build an executable, HelloWorld that uses useless to print a useless "Hello, world!" message. Source for this executable can sit in the root directory.
  5. Without modifying the build system, users of the build system should be able to turn on -Wall compile flag for all buid configurations, and -Wextra only for debug configurations. These flags, when enabled, should be applied to all build targets.
  6. Use CMake's transitive dependency resolution to ensure that HelloWorld has the simplest possible build system configuration.
  7. Public header files can go in a shared include folder under the root directory.

Clone this wiki locally