This recipe highlighted some new options to the ExternalProject_Add command:
- GIT_REPOSITORY: This can be used to specify the URL of the repository containing the sources of our dependency. CMake can also use other version control systems, such as CVS (CVS_REPOSITORY), SVN (SVN_REPOSITORY), or Mercurial (HG_REPOSITORY).
- GIT_TAG: By default, CMake will check out the default branch of the given repository. However, it is preferable to depend on a well-defined version that is known to be stable. This can be specified with this option, which can accept any identifier recognized by Git as "version" information, such as a Git commit SHA, a Git tag, or just a branch name. Similar options are also available for the other version control systems understood by CMake.
- TEST_AFTER_INSTALL: Most likely, your dependency has a test suite of its own and you might want to run the test suite to ensure that everything went smoothly during the superbuild. This option will run the tests right after the installation step.
The additional Test options understood by ExternalProject_Add are as follows:
- TEST_BEFORE_INSTALL, which will run the test suite before the installation step
- TEST_EXCLUDE_FROM_MAIN, with which we can remove the dependency on the main target of the external project from the test suite
These options assume that the external project manages testing using CTest. If the external project does not use CTest to manage testing, we can set the TEST_COMMAND option to execute tests.
Introducing the superbuild pattern even for modules that are part of your own project comes at the cost of introducing an additional layer, re-declaring small CMake projects, and passing configuration settings explicitly through ExternalProject_Add. The benefit of introducing this additional layer is a clear separation of variable and target scopes, which can help to manage complexity, dependencies, and namespaces in projects consisting of several components, where these components can be internal or external, and composed together by CMake.