Adding external projects - nenetto/CMakeTemplates GitHub Wiki
Well, now you know how to create your SuperBuild project and your libraries and executables solving the dependendies. But here comes a question
How can I add my friend's library to my project?
I would like to use a library that my friend is developing, and be updated if my friend does any change on it. The good point is that you do not need to download your friend's library, CMake will do that for you, automatically! :smile:
First, we need to grab some information about my friend's library:
- Repository URL: where my friend leave an open-source copy of the code. For tutorial purposes, we will use
ExternalLibrary
as friend's library that can be downloaded from here.
Once you get the URL, we will create, following this tutorial the library project. However, this time we will not create the folder into our SuperBuild project, we will do outside, in a temporal folder. This is because we want to grab the source code from the repository during my SuperBuild project compilation.
-
Here, copy the file
TemplateCreator-external.cmake
to yourProjects
folder but change the name for your friend Library's:ExternalLibrary\CMake\TemplateCreator-External.cmake
toMyAwesomeSuperBuild\Project\ExternalLibrary.cmake
. This tells to your SuperBuild that the project exists and the source is in a git repository. -
Finally, open
ExternalLibrary.cmake
and set the repository URL that you get from git. For example purposes we will usehttps://github.com/nenetto/ExternalLibrary
In the file, you have to change the line 3 from
set(EP_URL "git://github.com/username/${EP_NAME}.git")
to
set(EP_URL "git://github.com/nenetto/${EP_NAME}.git")
Important: The file *.cmake
must be called with your friend's library name. In this case ExternalLibrary.cmake
Configure again your SuperBuild, and you will find the option USE_ExternalLibrary
. So you can activate it and it will be downloaded and compiled together.