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 folderMyAwesomeSuperBuild
-
: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
andInternalLibrary
fromMyAwesomeSuperBuild
-
Delete the files:
InternalExecutable.cmake
,InternalLibrary.cmake
,ExternalExecutable.cmake
,ExternalLibrary.cmake
fromMyAwesomeSuperBuild/Projects
-
Finally, decide a cool name for your SuperBuild project such as
MyAwesomeSuperBuild
and go toCMakeLists.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
-
Go to github ->
Your profile
->Repositories
and click onNew
- In Repository name set the name for your repository. In this case, the name will be
MyAwesomeSuperBuild
and clickCreate Repository
.- Check the box
Initialize this repository with a README
. This will help in next step.
- Check the box
- Copy the URL that appear in the bottom of the web. Should be a name like
https://github.com/{YOUR USER NAME HERE}/MyAwesomeSuperBuild
- 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.
- 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
- 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
- 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.
- 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 calledPush
in git language.
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: