Create SuperBuild - nenetto/CMakeTemplates GitHub Wiki

This tutorial explains how to create your SuperBuild project from the scratch, how to configurate it using CMakeTemplates and how to upload it to a repository for version control at github.

The first part of the tutorial tells you how to create the basic structure for your SuperBuild using CMakeTemplates. The second part tells how to create your github repository and start developing using SmartGit for version control.

Create my Super Build project

Let say that you have a project in C/C++ and you want to use some functionalities from other libraries. You do not want to deal with tedious CMake configuration files to do it.

  • Download CMakeTemplates repository from here.

  • Open the folder and you will find the following folder structure

  • :open_file_folder: CMakeTemplates

    • :file_folder: CMakeProject
    • :file_folder: CMakeSuperBuildTemplate
    • :page_with_curl: README.md
  • Create your ProjectSuperBuild folder. For this example we will create the MyAwesomeSuperBuild

  • Copy the content of CMakeSuperBuildTemplate into your folder MyAwesomeSuperBuild

  • :open_file_folder: MyAwesomeSuperBuild

    • :file_folder: CMake
    • :file_folder: InternalExecutable
    • :file_folder: InternalLibrary
    • :file_folder: Projects
    • :page_with_curl: CMakeLists.txt

This example comes with 4 subprojects already added to the SuperBuild. You can play with them in order to understand better the behaviour of the template. However, for this tutorial we will delete them.

  • Delete the folders: InternalExecutable and InternalLibrary from MyAwesomeSuperBuild

  • Delete the files: InternalExecutable.cmake , InternalLibrary.cmake , ExternalExecutable.cmake , ExternalLibrary.cmake from MyAwesomeSuperBuild/Projects

  • Finally, decide a cool name for your SuperBuild project such as MyAwesomeSuperBuild and go to CMakeLists.txt file and change the line 14 from

set(MYPROJECT_NAME "TemplateSuperbuild" CACHE STRING "")

to

set(MYPROJECT_NAME "MyAwesomeSuperBuild" CACHE STRING "")

Now you created your Awesome Super Build. You are ready for the next step and create a github repository for changes tracking.

Create my Super Build repository on github

You will need:

  • A github account. You can create one here

  • Git installed in your computer. Download from here

    • Optionally you could want install a Git IDE such as SmartGit. This tutorial will use SmartGitfor repository management
  • Go to github -> Your profile -> Repositories and click on New

New Github Repository

  • In Repository name set the name for your repository. In this case, the name will be MyAwesomeSuperBuild and click Create Repository.
    • Check the box Initialize this repository with a README. This will help in next step.
  • Copy the URL that appear in the bottom of the web. Should be a name like
https://github.com/{YOUR USER NAME HERE}/MyAwesomeSuperBuild

URL

  • Once the repository is created on github, run SmartGit on your computer and go to Repository -> Clone and paste the URL name of your repository.

CloneSmartGit

  • Finally select a local folder in your computer where to write. This folder will be your development folder and the repository will be copied there. Your local folder after clone will appear in your computer as

Local1

  • Now, your repository is created, let's do the first commit with your MyAwesomeSuperBuild project.
    • Copy all the contents on MyAwesomeSuperBuild into local folder that you created for the repository
    • Your local folder or local repository should keep at this step like this

LocalEnd

  • Now, let's do the first commit and save the changes into the repository online. Go to SmartGit and double click in your project name MyAwesomeSuperBuild. Click on Commit button and in the open window select all files for the commit.

FirstCommit

  • Click on Commit & Push. This will create a first commit of your project with the current files. Also, it will update those changes into github repository. This remote update is what is called Push in git language.

Commit2

Now you can start working in your computer with your SuperBuild project. Just add new libraries, new dependencies, new executables, commit them and push to your remote repository so others could use it in their projects! :smile: