Package: dependencmake
DependenCmakeYet another dependency manager for projects usingCMake.According to CMakedocumentation, the best way to consume a CMake dependency is to install it and find it.
Using includes just creates mess.This helper can fetch, build and install CMake dependencies in a specific directory that you can add to your project with-DCMAKE_PREFIX_PATH.
It keeps your system environment clean as you won't mix libraries up.
This can be also convenient for Fortran projects where installing libraries is not the standard due to the volatility ofmodfiles.InstallThis package is managed withPoetry:pipinstallpoetryInstall from downloaded repository with:poetryinstall--no-devUsageThe generic usage of the command is:ENV=valuedependencmakeactionpath/to/cmake/dirwhich is pretty close to how CMake is called.
The program will fetch/build/install desired dependencies and stored the result of the different actions in adependencmakedirectory in the current directory.The program will look for adependencmake.yamlfile in the specified directory, where dependencies are listed:dependencies:-name:My dependencyurl:file://my_server/my_dep.zipcmake_args:-DUSE_MPI=ON-name:My other dependencyurl:http://my_repo/my_other_dep.gitgit_hash:25481515More info on the accepted parameters in theconfiguration filesection.The program accepts several actions:create-configto create a new configuration file;listto list dependencies collected in the configuration file;fetchto fetch dependencies and copy them on local disk;buildto fetch and build dependencies;installto fetch, build and install dependencies;cleanto clean the cache.Thebuildandinstallactions will take any other arguments and pass them directly to CMake at configure step.If you callfetch,buildorinstalla second time, already fetched dependencies will most likely not be fetched again.
Git dependencies will be pulled (unlessgit_no_updateis set) and other kind of dependencies will rest untouched.Example of workflow:mkdirbuildcdbuild
dependencmakeinstall..-DCMAKE_BUILD_TYPE=Release
cmake..-DCMAKE_PREFIX_PATH=$PWD/dependencmake/install-DCMAKE_BUILD_TYPE=Release
makethe-DCMAKE_INSTALL_PREFIXargument is required to tell CMake where dependencies are installed.It is possible to set the install prefix to a custom value with theinstall-prefixargument.
In this case dependencies will be installed in this directory instead of in the DependenCmake cache:mkdirbuildcdbuild
dependencmakeinstall--install-prefixlib/extern..-DCMAKE_BUILD_TYPE=Release
cmake..-DCMAKE_PREFIX_PATH=$PWD/lib/extern-DCMAKE_BUILD_TYPE=Release
makeConfiguration fileThe configuration file uses theYAML format.
It stores dependencies information in thedependencieskey as a list.
Each item contains the following possible keys:name:
Name of the dependency, used for display.
Mandatory;url:
URL where to get the dependency.
Can be a Git repository, online only (must end by.git),
an archive, online or local (must end by.zip,.tar,.tar.bz2,.tbz2,.tar.gz,.tgz,.tar.xzor.txz),
or a plain directory, local only.
Mandatory;git_hash:
Git hash to checkout to in case of Git repository.
The hash can be a commit hash or a tag.
Optional;git_no_update:
When set totrue, if the Git repository has been cloned, it will not been pulled on another run.
Optional;cmake_subdir:
Subdirectory where to find the CMakeLists.txt file if it is not in the top directory.
Optional;cmake_args:
Specific arguments to pass to CMake at configuration time.
Optional;jobs:
Number of jobs to use when building the dependency.
By default, number of CPU cores * 2 + 1.
Optional.CacheDependenCmake will put generated data in adependencmakecache folder in the current working directory:dependencmake/
+-- build/
+-- fetch/
+-- install/It's pretty clear what the purpose of each subfolder of the cache is.fetchandbuildboth contain a subfolder for each dependency.
The dependency directory name is the lower case and slugified name of the dependency, appended with a MD5 hash of the URL.
This allows to make the directory unique per couple name/URL and humanly readable.installhas no logic enforced and is populated according to theinstalldirectives of theCMakeLists.txtfiles of the dependencies.Additionnal checksAfter fetching dependencies, they are checked to detect patterns not managed by the program.
For now, diamond dependencies (where the same dependency is requested by two others) are invalid if they are not strictly equivalent.