CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

MIT License

Stars
2.6K

Bot releases are visible (Hide)

CPM.cmake - Respect DOWNLOAD_ONLY flag when CPM_<Package>_SOURCE is set

Published by TheLartians almost 3 years ago

Fixes an issue where the DOWNLOAD_ONLY flag is lost in combination with an overriding CPM_<Package>_SOURCE flag.
Thanks to @hacker-cb for the fix!

CPM.cmake - Fix issue that prevented passing lists as package arguments

Published by TheLartians almost 3 years ago

Fixed a problem that made passing lists as arguments impossible. Note that due to the way CMake handles parsing function arguments, separator semicolons of list arguments need to be quadruple escaped (\\\\;). See #302 for details.

CPM.cmake - CPM_USE_NAMED_CACHE_DIRECTORIES

Published by TheLartians about 3 years ago

Adds an option to add an additional directory layer to the cache, allowing some IDEs to display the proper dependency name. See #266 for details. Thanks @pgorgon-hem for the feature!

CPM.cmake - Detect when a cache directory has been modified

Published by TheLartians about 3 years ago

CPM.cmake now emits a warning when a dependencies source directory has been modified (git dependencies only). See #274 for details.
Thanks @apGribble and @andijcr for the suggestion and implementation!

CPM.cmake - Spaces in paths and FetchContent interoperability

Published by TheLartians about 3 years ago

  • Fixes an issue (#285) when spaces are used in the CPM.cmake path.
  • Fixes an issue (#287) when using "naked" FetchContent together with CPM.cmake.

Thanks to @MixusMinimax and @OlivierLDff for finding and fixing the issues!

CPM.cmake - Bitbucket support and relative paths

Published by TheLartians over 3 years ago

  • Projects hosted on Bitbucket can now be added through the named argument BITBUCKET_REPOSITORY or using the bb: prefix in the single-argument syntax. Thanks @pgorgon-hem for the PR!
  • Using a relative path for CMAKE_SOURCE_CACHE will now work thanks to a fix by @studoot!
CPM.cmake - Respect FETCHCONTENT_BASE_DIR if set by a user

Published by TheLartians over 3 years ago

Fixes an issue where a user-set FETCHCONTENT_BASE_DIR would be ignored when adding a cached dependency.

Thanks to @trxcllnt for the fix!

CPM.cmake - Options are now scoped to the dependency

Published by TheLartians over 3 years ago

Previously, function passed to a dependency were stored in the CMake cache. Following version 0.32.0, options are now scoped to the dependency and not leaked into the parent or CMake cache. This could potentially break projects, if relied on options entering the cache, however we assume that the change leads to a more predictable behaviour for almost all use cases. See #222 for a detailed discussion.

Additionally, the change means that we cannot (easily) check for option consistency, so the check has been disabled for now and is planned to be re-implemented in a further update.

CPM.cmake - Fix source subdirectories support

Published by TheLartians over 3 years ago

Fixes a bug that prevented SOURCE_SUBDIR from working as expected.

CPM.cmake - URL support in shorthand syntax

Published by TheLartians over 3 years ago

The shorthand syntax now supports URL patterns, inferring name and version automatically. Hash validation is also supported. See the readme or #220 for details.

Example

CPMAddPackage("https://example.com/my-package-1.2.3.zip#MD5=68e20f674a48be38d60e129f600faf7d")
CPM.cmake - Single-argument shorthand syntax

Published by TheLartians over 3 years ago

Adds a new single-argument shorthand syntax for CPMAddPackage, which tries to infer name, tag and version information from the provided argument string. See #205 and the readme for details.

Example

Before

CPMAddPackage(
  NAME catch2
  GITHUB_REPO catchorg/Catch2
  VERSION 2.5.0
  EXCLUDE_FROM_ALL YES
)

After

CPMAddPackage("gh:catchorg/[email protected]")
CPM.cmake - Infer name from git repo if possible

Published by TheLartians over 3 years ago

Now tries to infer the package name automatically from a given git repository URL. See #202 for details.

Example

CPMAddPackage(
  NAME Catch2
  GITHUB_REPOSITORY catchorg/Catch2
  VERSION 2.5.0
)

Is now equivalent to

CPMAddPackage(
  GITHUB_REPOSITORY catchorg/Catch2
  VERSION 2.5.0
)
CPM.cmake - Add option EXCLUDE_FROM_ALL

Published by TheLartians over 3 years ago

This adds an optional parameter EXCLUDE_FROM_ALL that prevents packages from leaking unwanted targets (such as tests, examples) to CPM.cmake projects. See #152 and #198 for details.

Usage example

CPMAddPackage(
  NAME googletest
  GITHUB_REPOSITORY google/googletest
  VERSION 1.8.0
  GIT_TAG release-1.8.0
  # prevent googletest targets from leaking into all
  EXCLUDE_FROM_ALL YES
)
CPM.cmake - Optionally add dependencies using EXCLUDE_FROM_ALL

Published by TheLartians over 3 years ago

This adds an optional parameter EXCLUDE_FROM_ALL that prevents packages from leaking unwanted targets (such as tests, examples) to CPM.cmake projects. This is a pre-release for testing the functionality. See #152 and #198 for details.

CPM.cmake - Add dependencies using EXCLUDE_FROM_ALL

Published by TheLartians over 3 years ago

This should prevent packages from leaking unwanted targets (such as tests, examples) to CPM.cmake projects. This is a pre-release for testing the functionality. See #152 and #198 for details.

CPM.cmake - Migrate to GitHub organisation

Published by TheLartians over 3 years ago

The CPM.cmake source code now resides at the brand new cpm-cmake organisation. This will help the project grow by organising related projects and managing collaborators. This release updates related URLs in the CPM.cmake script.

CPM.cmake - Fix super build issues

Published by TheLartians over 3 years ago

  • Fixed an issue caused by a bug in CMake < 3.17, where FetchContent wasn't properly included when importing CPM.cmake independently from different directories (#192).
  • Updated examples with newer versions and cleaner CMake code (#190).

Thanks to @ClausKlein and @xmuller for the PRs!

CPM.cmake - Prettify package lock

Published by TheLartians over 3 years ago

The package lock output is now prettified.

Before

# cxxopts
CPMDeclarePackage(cxxopts "NAME;cxxopts;VERSION;2.2.0;GITHUB_REPOSITORY;jarro2783/cxxopts;OPTIONS;CXXOPTS_BUILD_EXAMPLES Off;CXXOPTS_BUILD_TESTS Off")

After

# cxxopts
CPMDeclarePackage(cxxopts
  NAME cxxopts
  VERSION 2.2.0
  GITHUB_REPOSITORY jarro2783/cxxopts
  OPTIONS
    "CXXOPTS_BUILD_EXAMPLES Off"
    "CXXOPTS_BUILD_TESTS Off"
)

Thanks to @alexandreSalconiDenis for the suggestion and PR!

CPM.cmake - Expand CPM_SOURCE_CACHE path provided as a configure argument

Published by TheLartians over 3 years ago

Now supports non-absolute paths for CPM_SOURCE_CACHE passed through configuration arguments, e.g. -DCPM_SOURCE_CACHE=~/some/path.

See #186 for details.

CPM.cmake - Removed FetchContent overhead for cached packages

Published by TheLartians over 3 years ago

We now bypass FetchContent for cached dependencies, resulting in a substantial performance improvement per added dependency.