Skip to main content

Dependencies manager for projects using CMake

Project description

Build Status codecov

DependenCmake

Yet another dependency manager for projects using CMake.

According to CMake documentation, 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 of mod files.

Install

This package is managed with Poetry:

pip install poetry

Install from downloaded repository with:

poetry install --no-dev

Usage

The generic usage of the command is:

ENV=value dependencmake action path/to/cmake/dir

which 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 a dependencmake directory in the current directory.

The program will look for a dependencmake.yaml file in the specified directory, where dependencies are listed:

dependencies:
  - name: My dependency
    url: file://my_server/my_dep.zip
    cmake_args: -DUSE_MPI=ON
  - name: My other dependency
    url: http://my_repo/my_other_dep.git
    git_hash: 25481515

More info on the accepted parameters in the configuration file section.

The program accepts several actions:

  • create-config to create a new configuration file;
  • list to list dependencies collected in the configuration file;
  • fetch to fetch dependencies and copy them on local disk;
  • build to fetch and build dependencies;
  • install to fetch, build and install dependencies;
  • clean to clean the cache.

The build and install actions will take any other arguments and pass them directly to CMake at configure step.

If you call fetch, build or install a second time, already fetched dependencies will most likely not be fetched again. Git dependencies will be pulled (unless git_no_update is set) and other kind of dependencies will rest untouched.

Example of workflow:

mkdir build
cd build
dependencmake install .. -DCMAKE_BUILD_TYPE=Release
cmake .. -DCMAKE_PREFIX_PATH=$PWD/dependencmake/install -DCMAKE_BUILD_TYPE=Release
make

the -DCMAKE_INSTALL_PREFIX argument is required to tell CMake where dependencies are installed.

It is possible to set the install prefix to a custom value with the install-prefix argument. In this case dependencies will be installed in this directory instead of in the DependenCmake cache:

mkdir build
cd build
dependencmake install --install-prefix lib/extern .. -DCMAKE_BUILD_TYPE=Release
cmake .. -DCMAKE_PREFIX_PATH=$PWD/lib/extern -DCMAKE_BUILD_TYPE=Release
make

Configuration file

The configuration file uses the YAML format. It stores dependencies information in the dependencies key 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.xz or .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 to true, 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.

Cache

DependenCmake will put generated data in a dependencmake cache folder in the current working directory:

dependencmake/
+-- build/
+-- fetch/
+-- install/

It's pretty clear what the purpose of each subfolder of the cache is. fetch and build both 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. install has no logic enforced and is populated according to the install directives of the CMakeLists.txt files of the dependencies.

Additionnal checks

After 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dependencmake-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dependencmake-0.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file dependencmake-0.1.0.tar.gz.

File metadata

  • Download URL: dependencmake-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.13.2-1-default

File hashes

Hashes for dependencmake-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aa8d33f715efff255c18c7e6952ac9d08a10568a8c30c8c108ef74217b261d29
MD5 21a91e5ffe9a649a463bd7b175d7c1e6
BLAKE2b-256 b756020ddd36bd0024b150b4eb7ce03d0d65889dea9b5eb162aa662f0201ce6f

See more details on using hashes here.

File details

Details for the file dependencmake-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dependencmake-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Linux/5.13.2-1-default

File hashes

Hashes for dependencmake-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42e2eb209164e80aded428320ff88a6b4ad406c9dd481187de768fb9c67daa9d
MD5 ebce95cdf4828cb7393139a7d12b1585
BLAKE2b-256 dddc8aff74d41d171a43d927a24714c15fa22e0c34c93f44d0514a202eec00a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page