Create Executable - nenetto/CMakeTemplates GitHub Wiki
This tutorial explain how to create a CMake structure similar to CMake tutorials but using CMakeTemplates.
Starting point
Let say you have your SuperBuild project already created. For tutorial purposes we will use the previous SuperBuild that we created in previous tutorial lesson. This project was called MyAwesomeSuperBuild, and right now has nothing useful inside.
Now you want to develop a new executable that will be part of your SuperBuild project. For this purpose, we will use CMakeProject. Important: This project is NOT a template, it is a program to create your executable template. The trick part is this program runs on CMake, so we will need CMake Configure in order to create our executable template.
Steps
- First, we will decide a cool name for the executable, for example...
MyAwesomeFirstExecutable - Follow the instructions on Configure & Generate
- This time, your repository source will be the folder called
CMakeProject
- This time, your repository source will be the folder called

- Binary folder can be anywhere in your computer. It does not matter really.
- Before click on Configure button again, we need to set three options for our project
PROJECT_TYPE: Change toExecutablebecause we want to create an executablePROJECT_NAME_DEFAULT: Change to your executable nameMyAwesomeFirstExecutableSOURCE_DIR_DEFAULT: This is where source template for your Executable will be created. This option will be a folder with the same name of your executableMyAwesomeFirstExecutableinto your SuperBuild Project where you want to include itMyAwesomeSuperBuild

- Click on Configure and close CMake, it is done!
Now you created successfully your first project for an executable. We need to do something else, in order your SuperBuild can "see" the change and add it as a subproject.
- Go to your
MyAwesomeSuperBuildfolder, and there you will see a new folder with your executable's nameMyAwesomeFirstExecutable. Navigates inside to the CMake folder
MyAwesomeSuperBuild\MyAwesomeFirstExecutable\CMake
- Here, copy the file
TemplateCreator-internal.cmaketo yourProjectsfolder but change the name for your Executable's:MyAwesomeSuperBuild\MyAwesomeFirstExecutable\CMake\TemplateCreator-internal.cmaketoMyAwesomeSuperBuild\Projects\MyAwesomeFirstExecutable.cmake. This tells to your SuperBuild that the project exists and the source is in theMyAwesomeFirstExecutablefolder
Now you can start working. The template has a main function and some example functions. Uses the public header and the cpp for develop your own executable. If you want to add new header files or source (c/cpp) files, do it inside your source folder MyAwesomeFirstExecutable/inc and MyAwesomeFirstExecutable/src