Skip to content

Migos46/practising_cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello world app

App to practice some ways of configuring the build system with cmake. The app will print an "Usage message" if no arguments are introduce.

Options to configure the project

The foolowing options are available for this project:

  • DEBUG_BUILD
  • USE_LOG

DEGUG_BUILD is explained in the section below called Adding compile options.
USE_LOG is an option if the user wants to activate verbose from the application, it will enable all the prints so the user can redirect the output to a log file or just have them printed on the terminal.
To configure the project with this option, add one or both options to the cmake commnad like:
$ cmake -DDEBUG_BUILD=ON -DUSE_LOG=ON ..
$ cmake -DDEBUG_BUILD=ON ..
$ cmake -DUSE_LOG=ON .. `

Adding compile features

Using and INTERFACE library to add the c++ standard

Adding compile options

Palying with generator expresions to select whether or not the debugging flag should be added to the build system. An option called DEBUG_BUILD can be set to TRUE to enable debugging.

To build the hello-world app just:

  1. Create a build directory if there is not one in the project top directory, where the top CMakeLists.txt file is. For instance -> /home/$USER/myRepos/hello-vscode/
    $ mkdir build
    and go into that directory
    $ cd build
  2. Configure the project. Here you can set DEBUG_BUILD variable to true, false by default
    $ cmake -DDEBUG_BUILD=ON ..
    or if you don't want debug just run
    $ cmake ..
    A message like the following should appear after building correctly:
-- Configuring done
-- Generating done
-- Build files have been written to: "whatever path is your build directory created in step 1"  
  1. Run your program, if you selected debugging, try the debugger in VS Code. You will need to set correctly the launch.json under the .vscode folder. Usually this file can be automatically generated by vscode, tutorials on the official vscode web can be found. From the build directory run:
    $ ./vscode whateverArgument
    or
    $ ./vscode

About

Repo to practice cmake build system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published