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

Overview

Actions Status Actions Status Actions Status



Setup-free CMake dependency management

CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper around CMake's FetchContent module that adds version control, caching, a simple API and more.

Manage everything

Any downloadable project or resource can be added as a version-controlled dependency though CPM, it is not necessary to modify or package anything. Projects using modern CMake are automatically configured and their targets can be used immediately. For everything else, the targets can be created manually after the dependency has been downloaded (see the snippets below for examples).

Further reading

Usage

After CPM.cmake has been added to your project, the function CPMAddPackage can be used to fetch and configure a dependency. Afterwards, any targets defined in the dependency can be used directly. CPMAddPackage takes the following named parameters.

CPMAddPackage(
  NAME          # The unique name of the dependency (should be the exported target's name)
  VERSION       # The minimum version of the dependency (optional, defaults to 0)
  OPTIONS       # Configuration options passed to the dependency (optional)
  DOWNLOAD_ONLY # If set, the project is downloaded, but not configured (optional)
  [...]         # Origin parameters forwarded to FetchContent_Declare, see below
)

The origin may be specified by a GIT_REPOSITORY, but other sources, such as direct URLs, are also supported. If GIT_TAG hasn't been explicitly specified it defaults to v(VERSION), a common convention for git projects. On the other hand, if VERSION hasn't been explicitly specified, CPM can automatically identify the version from the git tag in some common cases. GIT_TAG can also be set to a specific commit or a branch name such as master, however this isn't recommended, as such packages will only be updated when the cache is cleared.

If an additional optional parameter EXCLUDE_FROM_ALL is set to a truthy value, then any targets defined inside the dependency won't be built by default. See the CMake docs for details.

A single-argument compact syntax is also supported:

# A git package from a given uri with a version
CPMAddPackage("[email protected]")
# A git package from a given uri with a git tag or commit hash
CPMAddPackage("uri#tag")
# A git package with both version and tag provided
CPMAddPackage("[email protected]#tag")

In the shorthand syntax if the URI is of the form gh:user/name, it is interpreted as GitHub URI and converted to https://github.com/user/name.git. If the URI is of the form gl:user/name, it is interpreted as a GitLab URI and converted to https://gitlab.com/user/name.git. If the URI is of the form bb:user/name, it is interpreted as a Bitbucket URI and converted to https://bitbucket.org/user/name.git. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the EXCLUDE_FROM_ALL flag.

The single-argument syntax also works for URLs:

# An archive package from a given url. The version is inferred
CPMAddPackage("https://example.com/my-package-1.2.3.zip")
# An archive package from a given url with an MD5 hash provided
CPMAddPackage("https://example.com/my-package-1.2.3.zip#MD5=68e20f674a48be38d60e129f600faf7d")
# An archive package from a given url. The version is explicitly given
CPMAddPackage("https://example.com/[email protected]")

After calling CPMAddPackage, the following variables are defined in the local scope, where is the name of the dependency.

  • _SOURCE_DIR is the path to the source of the dependency.
  • _BINARY_DIR is the path to the build directory of the dependency.
  • _ADDED is set to YES if the dependency has not been added before, otherwise it is set to NO.

For using CPM.cmake projects with external package managers, such as conan or vcpkg, setting the variable CPM_USE_LOCAL_PACKAGES will make CPM.cmake try to add a package through find_package first, and add it from source if it doesn't succeed.

In rare cases, this behaviour may be desirable by default. The function CPMFindPackage will try to find a local dependency via CMake's find_package and fallback to CPMAddPackage, if the dependency is not found.

Full CMakeLists Example

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

# create project
project(MyProject)

# add executable
add_executable(tests tests.cpp)

# add dependencies
include(cmake/CPM.cmake)
CPMAddPackage("gh:catchorg/[email protected]")

# link dependencies
target_link_libraries(tests Catch2)

See the examples directory for complete examples with source code and check below or in the wiki for example snippets.

Adding CPM

To add CPM to your current project, simply add the latest release of CPM.cmake or get_cpm.cmake to your project's cmake directory. The command below will perform this automatically.

mkdir -p cmake
wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake

You can also download CPM.cmake directly from your project's CMakeLists.txt. See the wiki for more details.

Updating CPM

To update CPM to the newest version, update the script in the project's root directory, for example by running the command above. Dependencies using CPM will automatically use the updated script of the outermost project.

Advantages

  • Small and reusable projects CPM takes care of all project dependencies, allowing developers to focus on creating small, well-tested libraries.
  • Cross-Platform CPM adds projects directly at the configure stage and is compatible with all CMake toolchains and generators.
  • Reproducible builds By versioning dependencies via git commits or tags it is ensured that a project will always be buildable.
  • Recursive dependencies Ensures that no dependency is added twice and all are added in the minimum required version.
  • Plug-and-play No need to install anything. Just add the script to your project and you're good to go.
  • No packaging required Simply add all external sources as a dependency.
  • Simple source distribution CPM makes including projects with source files and dependencies easy, reducing the need for monolithic header files or git submodules.

Limitations

  • No pre-built binaries For every new build directory, all dependencies are initially downloaded and built from scratch. To avoid extra downloads it is recommend to set the CPM_SOURCE_CACHE environmental variable. Using a caching compiler such as ccache can drastically reduce build time.
  • Dependent on good CMakeLists Many libraries do not have CMakeLists that work well for subprojects. Luckily this is slowly changing, however, until then, some manual configuration may be required (see the snippets below for examples). For best practices on preparing projects for CPM, see the wiki.
  • First version used In diamond-shaped dependency graphs (e.g. A depends on C@1.1 and B, which itself depends on C@1.2 the first added dependency will be used (in this case C@1.1). In this case, B requires a newer version of C than A, so CPM will emit a warning. This can be easily resolved by adding a new version of the dependency in the outermost project, or by introducing a package lock file.

For projects with more complex needs and where an extra setup step doesn't matter, it may be worth to check out an external C++ package manager such as vcpkg, conan or hunter. Dependencies added with CPMFindPackage should work with external package managers. Additionally, the option CPM_USE_LOCAL_PACKAGES will enable find_package for all CPM dependencies.

Comparison to FindPackage

The usual way to add libraries in CMake projects is to call find_package( ) and to link against libraries defined in a _LIBRARIES variable. While simple, this may lead to unpredictable builds, as it requires the library to be installed on the system and it is unclear which version of the library has been added. Additionally, it is difficult to cross-compile projects (e.g. for mobile), as the dependencies will need to be rebuilt manually for each targeted architecture.

CPM.cmake allows dependencies to be unambiguously defined and builds them from source. Note that the behaviour differs from find_package, as variables exported to the parent scope (such as _LIBRARIES ) will not be visible after adding a package using CPM.cmake. The behaviour can be achieved manually, if required.

Comparison to pure FetchContent / ExternalProject

CPM.cmake is a wrapper for CMake's FetchContent module and adds a number of features that turn it into a useful dependency manager. The most notable features are:

  • A simpler to use API
  • Version checking: CPM.cmake will check the version number of any added dependency and emit a warning if another dependency requires a more recent version.
  • Offline builds: CPM.cmake will override CMake's download and update commands, which allows new builds to be configured while offline if all dependencies are available locally.
  • Automatic shallow clone: if a version tag (e.g. v2.2.0) is provided and CPM_SOURCE_CACHE is used, CPM.cmake will perform a shallow clone of the dependency, which should be significantly faster while using less storage than a full clone.
  • Overridable: all CPMAddPackage can be configured to use find_package by setting a CMake flag, making it easy to integrate into projects that may require local versioning through the system's package manager.
  • Package lock files for easier transitive dependency management.
  • Dependencies can be overridden per-build using CMake CLI parameters.

ExternalProject works similarly as FetchContent, however waits with adding dependencies until build time. This has a quite a few disadvantages, especially as it makes using custom toolchains / cross-compiling very difficult and can lead to problems with nested dependencies.

Options

CPM_SOURCE_CACHE

To avoid re-downloading dependencies, CPM has an option CPM_SOURCE_CACHE that can be passed to CMake as -DCPM_SOURCE_CACHE= . This will also allow projects to be configured offline, as long as the dependencies have been added to the cache before. It may also be defined system-wide as an environmental variable, e.g. by exporting CPM_SOURCE_CACHE in your .bashrc or .bash_profile.

export CPM_SOURCE_CACHE=$HOME/.cache/CPM

Note that passing the variable as a configure option to CMake will always override the value set by the environmental variable.

You can use CPM_SOURCE_CACHE on GitHub Actions workflows cache and combine it with ccache, to make your CI faster. See the wiki for more info.

CPM_DOWNLOAD_ALL

If set, CPM will forward all calls to CPMFindPackage as CPMAddPackage. This is useful to create reproducible builds or to determine if the source parameters have all been set correctly. This can also be set as an environmental variable.

CPM_USE_LOCAL_PACKAGES

CPM can be configured to use find_package to search for locally installed dependencies first by setting the CMake option CPM_USE_LOCAL_PACKAGES. If the option CPM_LOCAL_PACKAGES_ONLY is set, CPM will emit an error if the dependency is not found locally. These options can also be set as environmental variables.

In the case that find_package requires additional arguments, the parameter FIND_PACKAGE_ARGUMENTS may be specified in the CPMAddPackage call. The value of this parameter will be forwarded to find_package.

CPM_USE_NAMED_CACHE_DIRECTORIES

If set, CPM use additional directory level in cache to improve readability of packages names in IDEs like CLion. It changes cache structure, so all dependencies are downloaded again. There is no problem to mix both structures in one cache directory but then there may be 2 copies of some dependencies. This can also be set as an environmental variable.

Local package override

Library developers are often in the situation where they work on a locally checked out dependency at the same time as on a consumer project. It is possible to override the consumer's dependency with the version by supplying the CMake option CPM_ _SOURCE set to the absolute path of the local library. For example, to use the local version of the dependency Dep at the path /path/to/dep, the consumer can be built with the following command.

cmake -Bbuild -DCPM_Dep_SOURCE=/path/to/dep

Package lock

In large projects with many transitive dependencies, it can be useful to introduce a package lock file. This will list all CPM.cmake dependencies and can be used to update dependencies without modifying the original CMakeLists.txt. To use a package lock, add the following line directly after including CPM.cmake.

CPMUsePackageLock(package-lock.cmake)

To create or update the package lock file, build the cpm-update-package-lock target.

cmake -Bbuild
cmake --build build --target cpm-update-package-lock

See the wiki for more info.

Built with CPM.cmake

Some amazing projects that are built using the CPM.cmake package manager. If you know others, feel free to add them here through a PR.

otto-project

OTTO - The Open Source GrooveBox

maphi

Maphi - the Math App

modern-cpp-starter

ModernCppStarter

Snippets

These examples demonstrate how to include some well-known projects with CPM. See the wiki for more snippets.

Catch2

CPMAddPackage("gh:catchorg/[email protected]")

Range-v3

CPMAddPackage("gh:ericniebler/range-v3#0.11.0")

Yaml-cpp

# as the tag is in an unusual format, we need to explicitly specify the version
CPMAddPackage("gh:jbeder/yaml-cpp#[email protected]")

nlohmann/json

CPMAddPackage(
  NAME nlohmann_json
  VERSION 3.9.1
  OPTIONS 
    "JSON_BuildTests OFF"
)

Boost

# boost is a huge project and will take a while to download
# using `CPM_SOURCE_CACHE` is strongly recommended
CPMAddPackage(
  NAME Boost
  VERSION 1.77.0
  GITHUB_REPOSITORY "boostorg/boost"
  GIT_TAG "boost-1.77.0"
)

cxxopts

# the install option has to be explicitly set to allow installation
CPMAddPackage(
  GITHUB_REPOSITORY jarro2783/cxxopts
  VERSION 2.2.1
  OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
)

google/benchmark

CPMAddPackage(
  NAME benchmark
  GITHUB_REPOSITORY google/benchmark
  VERSION 1.5.2
  OPTIONS "BENCHMARK_ENABLE_TESTING Off"
)

if(benchmark_ADDED)
  # enable c++11 to avoid compilation errors
  set_target_properties(benchmark PROPERTIES CXX_STANDARD 11)
endif()

Lua

) endif()">
CPMAddPackage(
  NAME lua
  GIT_REPOSITORY https://github.com/lua/lua.git
  VERSION 5.3.5
  DOWNLOAD_ONLY YES
)

if (lua_ADDED)
  # lua has no CMake support, so we create our own target

  FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
  list(REMOVE_ITEM lua_sources "${lua_SOURCE_DIR}/lua.c" "${lua_SOURCE_DIR}/luac.c")
  add_library(lua STATIC ${lua_sources})

  target_include_directories(lua
    PUBLIC
      $<BUILD_INTERFACE:${lua_SOURCE_DIR}>
  )
endif()

For a full example on using CPM to download and configure lua with sol2 see here.

Full Examples

See the examples directory for full examples with source code and check out the wiki for many more example snippets.

Comments
  • Scope package options to avoid changing the local scope

    Scope package options to avoid changing the local scope

    This is the fix for #222, but I found a strange behaviour. Bellow is a test code :

    cmake_minimum_required(VERSION 3.14)
    project(TestOptions)
    
    include("cmake/CPM.cmake")
    
    set(SET "main")
    message(STATUS "From main before set:${SET}, option: ${OPT}")
    
    
    CPMAddPackage(
      NAME titi
      GIT_REPOSITORY https://gitlab.com/flagarde/titi
      GIT_TAG main 
      OPTIONS "OPT ON" "SET YU"
    )
    message(STATUS "From main between set:${SET}, option: ${OPT}")
    
    CPMAddPackage(
      NAME toto
      GIT_REPOSITORY https://gitlab.com/flagarde/toto
      GIT_TAG main 
      OPTIONS "OPT OFF" "SET CHANGE"
    )
    
    message(STATUS "From main after set:${SET}, option: ${OPT}")
    

    First run gives:

    -- The C compiler identification is GNU 10.2.0
    -- The CXX compiler identification is GNU 10.2.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- From main before set:main, option: 
    -- CPM: adding package titi@ (main)
    -- From titi, set: titi default was "titi" , option: ON default was "FALSE"
    -- From main between set:main, option: 
    -- CPM: adding package toto@ (main)
    -- From toto, set: CHANGE default was "toto" , option: OFF default was "TRUE"
    -- From main after set:main, option: 
    -- Configuring done
    -- Generating done
    

    -- From titi, set: titi default was "titi" , option: ON default was "FALSE" should be -- From titi, set: YU default was "titi" , option: ON default was "FALSE".

    Second gives the good results :

    -- From main before set:main, option: 
    -- CPM: adding package titi@ (main)
    -- From titi, set: YU default was "titi" , option: ON default was "FALSE"
    -- From main between set:main, option: 
    -- CPM: adding package toto@ (main)
    -- From toto, set: CHANGE default was "toto" , option: OFF default was "TRUE"
    -- From main after set:main, option: 
    -- Configuring done
    -- Generating done
    
    opened by flagarde 28
  • Allowing EXCLUDE_FROM_ALL

    Allowing EXCLUDE_FROM_ALL

    Hi @TheLartians ,

    Thanks for the library.

    When I include a CMake library with CPM.cmake it runs all the install commands in that library even when I don't need these installers with my own library.

    When adding the library as a subdirectory, it's possible to use add_subdirectory(libname EXCLUDE_FROM_ALL) to avoid that behavior.

    Is it possible to use EXCLUDE_FROM_ALL when downloading a CMake library?

    I don't know if that's a question or an enhancement.

    Best,

    enhancement 
    opened by alandefreitas 24
  • Parent project options are being cancelled

    Parent project options are being cancelled

    If the parent project has an option that conflicts with the child project, the child project is messing with the scope of the parent project.

    For instance

    message("BUILD_EXAMPLES=${BUILD_EXAMPLES}")
    CPMAddPackage(
            NAME pareto
            GIT_REPOSITORY https://github.com/alandefreitas/pareto.git
            GIT_TAG v1.2.0
            OPTIONS
            "BUILD_MATPLOT_TARGETS OFF"
            "BUILD_EXAMPLES OFF"
    )
    add_executable(spatial_containers spatial_containers.cpp)
    target_link_libraries(spatial_containers PUBLIC pareto)
    message("BUILD_EXAMPLES=${BUILD_EXAMPLES}")
    

    gives me

    BUILD_EXAMPLES=ON
    -- CPM: adding package [email protected] (v1.2.0)
    -- Looking for min
    -- Looking for min - not found
    BUILD_EXAMPLES=OFF
    

    which is a problem because some option names are quite common. Some projects create have prefixes in their options but most projects don't.

    Of course, people can manually do

    set(BUILD_EXAMPLES_PREV ${BUILD_EXAMPLES})
    message("BUILD_EXAMPLES=${BUILD_EXAMPLES}")
    CPMAddPackage(
            NAME pareto
            GIT_REPOSITORY https://github.com/alandefreitas/pareto.git
            GIT_TAG v1.2.0
            OPTIONS
            "BUILD_EXAMPLES OFF"
    )
    add_executable(spatial_containers spatial_containers.cpp)
    target_link_libraries(spatial_containers PUBLIC pareto)
    set(BUILD_EXAMPLES ${BUILD_EXAMPLES_PREV} CACHE BOOL "" FORCE)
    message("BUILD_EXAMPLES=${BUILD_EXAMPLES}")
    

    for all options but that defeats the purpose of the OPTIONS arguments, which is to do what we cannot already do with FetchContent.

    bug 
    opened by alandefreitas 19
  • Confused by the build stage

    Confused by the build stage

    I am wondering if someone could help me understand an issue that I have with the CPM. I can integrated it, no problem. But for some reason, when I build my project. CPM starts to mix up everything. It creates a lib, and bin directory in my build directory and shuffles everything around. I don't exactly know what happened that CPM doesn't put things in their respected -build, -install folders anymore.

    I should probably mention that I'm using the ExternalPackage as well, and direct them to the same _deps directory. But, I don't think that should cause the problem. I feel that somehow, CPM triggers an install target for some reason! I am not sure.

    Thanks for your help in advance!

    opened by amirmasoudabdol 18
  • How to only include public headers?

    How to only include public headers?

    Module in question https://github.com/martell/pthreads-win32.cmake/blob/master/CMakeLists.txt

    This is a cmake adaptation on top of the original pthreads-win32 library. The original library has header/source file in a single directory.

    The cmake adaptation makes proper install targets and move the header/complied libs into the proper location (see below)

    install(TARGETS ${PTHREADS_LIBRARY}
    	RUNTIME DESTINATION ${PTHREADS_BINDIR} COMPONENT ${PTHREADS_BINCOMPONENT}
    	LIBRARY DESTINATION ${PTHREADS_LIBDIR} COMPONENT ${PTHREADS_LIBCOMPONENT}
    	ARCHIVE DESTINATION ${PTHREADS_LIBDIR} COMPONENT ${PTHREADS_LIBCOMPONENT}
    	PUBLIC_HEADER DESTINATION ${PTHREADS_INCLUDEDIR} COMPONENT ${PTHREADS_INCLUDECOMPONENT})
    

    When adding this library using CPMAddPackage(), I needed to do something like target_include_libraries(TARGET INTERFACE <PATH_TO_SOURCE_DIR>) This adds all .h files as include headers, not just the public header.

    My understanding is that CPM does not trigger the "install" step, but just the "configure/build" steps when adding a package.

    Is there anyway to only include the public header?

    Thank you!

    Here's how I am adding that library via CPM

    # ---- pthreads for MSVC-----------
    if(MSVC)
      CPMAddPackage(
              NAME pthreads-win32
              SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../external/pthreads-win32
      )
      print_target_properties(pthreadsVC2)
    endif()
    

    The print_target_properties is a debug function to dump all target properties, its output is:

    Library name of pthreads-win32: pthreadsVC2.
    pthreadsVC2 AUTOGEN_ORIGIN_DEPENDS = ON
    pthreadsVC2 AUTOMOC_COMPILER_PREDEFINES = ON
    pthreadsVC2 AUTOMOC_MACRO_NAMES = Q_OBJECT;Q_GADGET;Q_NAMESPACE
    pthreadsVC2 AUTOMOC_PATH_PREFIX = ON
    pthreadsVC2 BINARY_DIR = C:/Users/justb/Repos/kintek-explorer/cmake-build-debug/_deps/pthreads-win32-build
    pthreadsVC2 BUILD_WITH_INSTALL_RPATH = FALSE
    pthreadsVC2 DEBUG_POSTFIX = d
    pthreadsVC2 IMPORTED = FALSE
    pthreadsVC2 IMPORTED_GLOBAL = FALSE
    pthreadsVC2 INCLUDE_DIRECTORIES = C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32
    pthreadsVC2 INSTALL_NAME_DIR = @executable_path/../lib
    pthreadsVC2 INSTALL_RPATH = $ORIGIN/../lib
    pthreadsVC2 INSTALL_RPATH_USE_LINK_PATH = TRUE
    pthreadsVC2 NAME = pthreadsVC2
    pthreadsVC2 POSITION_INDEPENDENT_CODE = True
    pthreadsVC2 PUBLIC_HEADER = C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/pthread.h;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/sched.h;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/semaphore.h
    pthreadsVC2 SKIP_BUILD_RPATH = FALSE
    pthreadsVC2 SOURCES = C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/attr.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/barrier.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/cancel.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/cleanup.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/condvar.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/create.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/dll.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/autostatic.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/errno.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/exit.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/fork.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/global.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/misc.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/mutex.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/nonportable.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/private.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/rwlock.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/sched.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/semaphore.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/signal.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/spin.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/sync.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/tsd.c;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/pthread.h;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/sched.h;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/semaphore.h;C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32/pthreads-win32/version.rc
    pthreadsVC2 SOURCE_DIR = C:/Users/justb/Repos/kintek-explorer/external/pthreads-win32
    pthreadsVC2 TYPE = SHARED_LIBRARY
    pthreadsVC2 UNITY_BUILD_BATCH_SIZE = 8 
    
    enhancement help desk 
    opened by bolu-atx 17
  • Unknown CMake command

    Unknown CMake command "CPMAddPackage"

    Hi, I'm facing this problem when reloading the CMake configuration on CLion.

    Unknown CMake command "CPMAddPackage"

    The problem disappears if I remove the checks that starts with if(CPM_DIRECTORY) in the CPM.cmake. What I can tell you is that it comes from the CMakeCache.txt, there's probably a cached option that is preventing your script from going on and declare the functions needed.

    Tried with both the bundled CMake 3.17 that the latest CMake binaries (3.19+).

    opened by NicholasBertazzon 15
  • Trouble linking crossplatform library 🙏

    Trouble linking crossplatform library 🙏

    Full reproduction: https://github.com/developer239/test_cpm Repository that I can't link: https://github.com/smasherprog/screen_capture_lite

    # CMAkeList.txt
    
    cmake_minimum_required(VERSION 3.19)
    project(test_cpm)
    
    set(CMAKE_CXX_STANDARD 14)
    
    # CPM
    set(CPM_DOWNLOAD_VERSION 0.27.2)
    set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
    
    if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
        message(STATUS "Downloading CPM.cmake")
        file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
    endif()
    
    include(${CPM_DOWNLOAD_LOCATION})
    
    # EXECUTABLES
    
    add_executable(test_cpm main.cpp)
    
    # DEPENDENCIES
    
    CPMAddPackage(NAME spdlog GITHUB_REPOSITORY gabime/spdlog VERSION 1.7.0)
    
    CPMAddPackage(
            NAME Screen_Capture
            GITHUB_REPOSITORY smasherprog/screen_capture_lite
            GIT_TAG 17.0.3
    )
    
    target_link_libraries(test_cpm spdlog Screen_Capture)
    
    # main.cpp
    
    #include <spdlog/spdlog.h>
    #include <Screen_Capture.h>
    
    int main() {
        spdlog::info("Hello world!");
        return 0;
    }
    

    Log:

    Maybe I misunderstood how does the linking work? 🤔 I had very similar problem with opencv.

    fatal error: 'Screen_Capture.h' file not found
    #include <Screen_Capture.h>
    

    image

    opened by developer239 13
  • Timestamps for URL downloads match the download time

    Timestamps for URL downloads match the download time

    By enabling CMake policy 135 we ensure that extracted files timestamp match that of the download time, instead of when the archive is created. This makes sure that if the URL changes to an older version we still rebuild everything as the timestamp stays newer.

    opened by robertmaynard 10
  • Setting CPM_SOURCE_ROOT from the environment

    Setting CPM_SOURCE_ROOT from the environment

    I use similar dependencies for various project, so that new feature would help me a lot. Is there a way to setup an environment variable for it? I would set CPM_SOURCE_ROOT per machine/user not per project. I would point in to $HOME/.cache/CPM or similar

    enhancement 
    opened by aggsol 10
  • Weird issue with CPM_SOURCE_CACHE and FetchContent

    Weird issue with CPM_SOURCE_CACHE and FetchContent

    In the top-level project there is https://github.com/vtil-project/VTIL-Utils/blob/master/cmake/VTIL-Core.cmake:

    CPMAddPackage(
        NAME VTIL-Core
        GIT_REPOSITORY https://github.com/mrexodia/VTIL-Core
        GIT_TAG e6debb384cb218caff8cb94f50f00076b994a762
    )
    

    And after that it includes https://github.com/vtil-project/VTIL-Utils/blob/master/cmake/VTIL-NativeLifters.cmake:

    CPMAddPackage(
        NAME VTIL-NativeLifters
        GIT_REPOSITORY https://github.com/vtil-project/VTIL-NativeLifters
        GIT_TAG f8837ef4d2412a5a1c25f725f25685a23e1cf1a1
    )
    

    Inside the VTIL-NativeLifters repo there is a FetchContent call with the name VTIL-Core, The idea here is that you can pin a different version of VTIL-Core in your project that will then be used to compile the VTIL-NativeLifters library.

    https://github.com/vtil-project/VTIL-NativeLifters/blob/master/Dependencies/CMakeLists.txt#L4:

    include(FetchContent)
    
    message(STATUS "Fetching VTIL-Core (this might take a while)...")
    FetchContent_Declare(
        VTIL-Core
        GIT_REPOSITORY https://github.com/vtil-project/VTIL-Core
        GIT_TAG        eeffb26b8b9ef7b4bd6ffbfc09f3133b70b36eda
        GIT_SHALLOW    false
    )
    FetchContent_MakeAvailable(VTIL-Core)
    

    When using CPM_SOURCE_CACHE CMake errors out:

    D:\CodeBlocks\VTIL-Utils\build>cmake ..
    -- Building for: Visual Studio 16 2019
    -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
    -- The C compiler identification is MSVC 19.29.30038.1
    -- The CXX compiler identification is MSVC 19.29.30038.1
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Fetching capstone (this might take a while)...
    CMake Deprecation Warning at build/_deps/capstone-src/CMakeLists.txt:1 (cmake_minimum_required):
      Compatibility with CMake < 2.8.12 will be removed from a future version of
      CMake.
    
      Update the VERSION argument <min> value or use a ...<max> suffix to tell
      CMake that the project does not need compatibility with older versions.
    
    
    CMake Deprecation Warning at build/_deps/capstone-src/CMakeLists.txt:18 (cmake_policy):
      The OLD behavior for policy CMP0048 will be removed from a future version
      of CMake.
    
      The cmake-policies(7) manual explains that the OLD behaviors of all
      policies are deprecated and that a policy should be set to OLD only under
      specific short-term circumstances.  Projects should be ported to the NEW
      behavior and not rely on setting a policy to OLD.
    
    
    Enabling CAPSTONE_ARM_SUPPORT
    Enabling CAPSTONE_ARM64_SUPPORT
    Enabling CAPSTONE_M68K_SUPPORT
    Enabling CAPSTONE_MIPS_SUPPORT
    Enabling CAPSTONE_PPC_SUPPORT
    Enabling CAPSTONE_SPARC_SUPPORT
    Enabling CAPSTONE_SYSZ_SUPPORT
    Enabling CAPSTONE_XCORE_SUPPORT
    Enabling CAPSTONE_X86_SUPPORT
    Enabling CAPSTONE_TMS320C64X_SUPPORT
    Enabling CAPSTONE_M680X_SUPPORT
    Enabling CAPSTONE_EVM_SUPPORT
    Enabling CAPSTONE_MOS65XX_SUPPORT
    -- Fetching keystone (this might take a while)...
    -- Looking for pthread.h
    -- Looking for pthread.h - not found
    -- Found Threads: TRUE
    -- CPM: adding package [email protected] (e6debb384cb218caff8cb94f50f00076b994a762 at d:/cpm_cache/vtil-core/b00df6cc2b142d6fa5bce7908fa7339da177c741)
    -- Fetching VTIL-Core (this might take a while)...
    CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FetchContent.cmake:1206 (add_subdirectory):
      The binary directory
    
        D:/CodeBlocks/VTIL-Utils/build/_deps/vtil-core-build
    
      is already used to build a source directory.  It cannot be used to build
      source directory
    
        D:/CodeBlocks/VTIL-Utils/build/_deps/vtil-core-src
    
      Specify a unique binary directory name.
    Call Stack (most recent call first):
      D:/cpm_cache/vtil-nativelifters/b0b7a3915a18707147fb220d4cf2d2f76e9d8d8d/Dependencies/CMakeLists.txt:10 (FetchContent_MakeAvailable)
    
    
    -- CPM: adding package [email protected] (f8837ef4d2412a5a1c25f725f25685a23e1cf1a1 at d:/cpm_cache/vtil-nativelifters/b0b7a3915a18707147fb220d4cf2d2f76e9d8d8d)
    -- CPM: adding package [email protected] (ae22269df734a2b0957a9ab4e37be41f61866dbe at d:/cpm_cache/args/0fef5c19d6fb87e7b5acefd2362b022afaf2dab6)
    -- CPM: adding package [email protected] (v0.0.5 at d:/cpm_cache/cpmlicenses.cmake/2e9893c848f8cf158d41d1c4737a276bac779ef3)
    -- Configuring incomplete, errors occurred!
    See also "D:/CodeBlocks/VTIL-Utils/build/CMakeFiles/CMakeOutput.log".
    See also "D:/CodeBlocks/VTIL-Utils/build/CMakeFiles/CMakeError.log".
    

    Without CPM_SOURCE_CACHE everything works as intended:

    D:\CodeBlocks\VTIL-Utils\build>cmake ..
    -- Building for: Visual Studio 16 2019
    -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
    -- The C compiler identification is MSVC 19.29.30038.1
    -- The CXX compiler identification is MSVC 19.29.30038.1
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- CPM: adding package [email protected] (e6debb384cb218caff8cb94f50f00076b994a762)
    -- Fetching capstone (this might take a while)...
    CMake Deprecation Warning at build/_deps/capstone-src/CMakeLists.txt:1 (cmake_minimum_required):
      Compatibility with CMake < 2.8.12 will be removed from a future version of
      CMake.
    
      Update the VERSION argument <min> value or use a ...<max> suffix to tell
      CMake that the project does not need compatibility with older versions.
    
    
    CMake Deprecation Warning at build/_deps/capstone-src/CMakeLists.txt:18 (cmake_policy):
      The OLD behavior for policy CMP0048 will be removed from a future version
      of CMake.
    
      The cmake-policies(7) manual explains that the OLD behaviors of all
      policies are deprecated and that a policy should be set to OLD only under
      specific short-term circumstances.  Projects should be ported to the NEW
      behavior and not rely on setting a policy to OLD.
    
    
    Enabling CAPSTONE_ARM_SUPPORT
    Enabling CAPSTONE_ARM64_SUPPORT
    Enabling CAPSTONE_M68K_SUPPORT
    Enabling CAPSTONE_MIPS_SUPPORT
    Enabling CAPSTONE_PPC_SUPPORT
    Enabling CAPSTONE_SPARC_SUPPORT
    Enabling CAPSTONE_SYSZ_SUPPORT
    Enabling CAPSTONE_XCORE_SUPPORT
    Enabling CAPSTONE_X86_SUPPORT
    Enabling CAPSTONE_TMS320C64X_SUPPORT
    Enabling CAPSTONE_M680X_SUPPORT
    Enabling CAPSTONE_EVM_SUPPORT
    Enabling CAPSTONE_MOS65XX_SUPPORT
    -- Fetching keystone (this might take a while)...
    -- Looking for pthread.h
    -- Looking for pthread.h - not found
    -- Found Threads: TRUE
    -- CPM: adding package [email protected] (f8837ef4d2412a5a1c25f725f25685a23e1cf1a1)
    -- Fetching VTIL-Core (this might take a while)...
    -- CPM: adding package [email protected] (ae22269df734a2b0957a9ab4e37be41f61866dbe)
    -- CPM: adding package [email protected] (v0.0.5)
    -- Configuring done
    -- Generating done
    -- Build files have been written to: D:/CodeBlocks/VTIL-Utils/build
    

    This is cmake 3.20.5 btw

    opened by mrexodia 9
  • find_package and CPMFindPackage have different behaviors

    find_package and CPMFindPackage have different behaviors

    Hello,

    I'm using CPMFindPackage() to check for a dependency on CMocka and noticing some strange behavior with the find_package portion. Do you know what I might be doing wrong here?

    CPMFindPackage(
      NAME CMOCKA
      GIT_REPOSITORY https://git.cryptomilk.org/projects/cmocka.git/
      VERSION 1.1.5
      GIT_TAG cmocka-1.1.5
      OPTIONS
        "WITH_EXAMPLES OFF"
    )
    
    message("CMOCKA_FOUND: ${CMOCKA_FOUND}")
    message("CMOCKA_ADDED: ${CMOCKA_ADDED}")
    message("CMOCKA_INCLUDES: ${CMOCKA_INCLUDE_DIR}")
    message("CMOCKA_LIBRARIES: ${CMOCKA_LIBRARIES}")
    

    The library is installed on my system with a CMake config file. I see this output from CPM, but the FOUND/ADDED variables are not set, and the other variables defined by the config file aren't used.

    -- CPM: using local package [email protected]
    CMOCKA_FOUND:
    CMOCKA_ADDED:
    CMOCKA_INCLUDES:
    CMOCKA_LIBRARIES:
    

    If I remove CPMFindPackage and add find_package:

    find_package(CMOCKA)
    

    This time, CMOCKA_FOUND will be defined, and the values defined by the config file are used.

    CMOCKA_FOUND: 1
    CMOCKA_ADDED:
    CMOCKA_INCLUDES: /usr/local/include
    CMOCKA_LIBRARIES: /usr/local/lib/libcmocka.dylib
    
    documentation 
    opened by phillipjohnston 9
  • `CPMAddPackage` does not `export` variables when finding local packages.

    `CPMAddPackage` does not `export` variables when finding local packages.

    At first, I used CPMFindPackage to add third-party dependencies, because I wanted CPM to first find out if there was a package that needed to be installed locally, and then download and install it if there wasn't.

    But then I noticed that CPMFindPackage does not export variables if it finds a locally installed package.

    Then I noticed that if I use CPMAddPackage and define CPM_USE_LOCAL_PACKAGES I can also achieve the same function and export the variables after it finds the locally installed packages.

    The problem is that I can't use the exported variables even though the logs output using local package.

    My CMake code is roughly like this:

    CPMAddPackage(
    		NAME CURL
    		GIT_TAG curl-7_87_0
    		GITHUB_REPOSITORY "curl/curl"
    		OPTIONS "CURL_USE_OPENSSL"
    )
    
    # set(linked_project CURL)
    if (${linked_project}_ADDED)
    		# downloaded
    		message(STATUS "Successfully added [${linked_project}], the source files path is [${${linked_project}_SOURCE_DIR}], the binary files path is [${${linked_project}_BINARY_DIR}]!")
    		# add_subdirectory(
    		# 		${${linked_project}_SOURCE_DIR}
    		# 		${${linked_project}_BINARY_DIR}
    		# 		EXCLUDE_FROM_ALL
    		# )
    else ()
    		message(FATAL_ERROR "Library [${linked_project}] not found!")
    endif (${linked_project}_ADDED)
    

    Everything works fine on Windows and Linux, but not on MacOS. I don't have a MacOS environment to test in, so I'm relying on GitHub Workflows.

    opened by Life4gal 0
  • Add option to allow `CPMFindPackage` to behave as `find_package`

    Add option to allow `CPMFindPackage` to behave as `find_package`

    We currently use CPMFindPackage as a way to try to find a package if it currently exists on the users system, but then fall back to fetching it and building it from source if it doesn't currently exist. This works great for users in practice because generally it makes the builds just work which is the goal.

    Unfortunately, one of the downsides to this is that for us as library maintainers and packagers, we can run into issues where in a packaging flow we expect to have all of the packages installed on the system, but if we miss something then it falls back to CPMAddPackage and can lead to us erroneously bundling that dependency in our package.

    It would be great if there were options that had the opposite behavior of CPM_DOWNLOAD_ALL and CPM_DOWNLOAD_<dependency name> that would prevent fetching the package from source if it was failed to be found.

    opened by kkraus14 0
  • Error while trying to run cmake with `-DCPM_<name>_SOURCE` on dependency that is also added to subdendencies.

    Error while trying to run cmake with `-DCPM__SOURCE` on dependency that is also added to subdendencies.

    Given following dependency diagram:

    Diagram bez tytułu drawio Consumer depends on [email protected] and [email protected], libA depends on [email protected]

    Minimal example: https://github.com/pszem0c/consumer

    If i try to run cmake for consumer project with flag -DCPM_libB_SOURCE it gives me error:

    CMake Warning at cmake-build-debug/cmake/CPM_0.36.0.cmake:310 (message):
      CPM: requires a newer version of libB (1.0.0) than currently included ().
    Call Stack (most recent call first):
      cmake-build-debug/cmake/CPM_0.36.0.cmake:608 (cpm_check_if_package_already_added)
      CMakeLists.txt:5 (CPMAddPackage)
    

    CMake version: 3.25.1

    opened by pszem0c 1
  • Update example dependency versions

    Update example dependency versions

    This PR updates versions of dependencies used in examples for better compatibility with new hardware and CMake versions.

    Motivation

    It seems that the GitHub runner image ubuntu-latest was updated to use recent versions C++ build tools, resulting in some errors from various dependencies. These seem to already be addressed in more recent versions so we can simply update the dependencies to be compatible with the newest GitHub runners.

    Might fix issues currently blocking #427 from continuing.

    opened by TheLartians 0
  • A B A Cyclic dependencies

    A B A Cyclic dependencies

    (Probably been asked before, but I can't find doc's on this) libA -> libB -> libA. What I expect is that when libB is constructed, it will discover that libA is already being built, so will not attempt to re-add it. What I see is that the add_library in libA will be executed twice and cmake will complain that the library is already being built.

    Is there a solution to this apart from breaking the cyclic dependency by hand?

    Thanks

    opened by markfoodyburton 2
  • Question: Is there an equivalent option to ExternalProject_Add GIT_SUBMODULES?

    Question: Is there an equivalent option to ExternalProject_Add GIT_SUBMODULES?

    Some projects like Qt can be configured based on what submodules are available. Is there a method to restrict what submodules get inited with CPM?

    example:

    set(MODULES
        qtshadertools
        qt5compat
        qtlocation
        qtpositioning
        qtmultimedia
        qtwebchannel
        qtimageformats
        qtxmlpatterns
        qtrepotools
        qtsvg
        qtbase
        qttools
        qtwebsockets
        qtwebglplugin
        qtdeclarative
        )
    
    ExternalProject_Add(qt
        GIT_REPOSITORY "https://code.qt.io/qt/qt5.git"
        GIT_SUBMODULES ${MODULES}
    
    opened by shadowpsi 1
Releases(v0.36.0)
  • v0.36.0(Oct 4, 2022)

    What's Changed

    • Fix: CPMFmtExample by @AlessandroW in https://github.com/cpm-cmake/CPM.cmake/pull/410
    • Updated contributor list by @iboB in https://github.com/cpm-cmake/CPM.cmake/pull/411
    • Add CONTRIBUTING.md by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/412
    • Update example in readme by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/413
    • Added export of CPM_LAST_PACKAGE_NAME by @CraigHutchinson in https://github.com/cpm-cmake/CPM.cmake/pull/403

    New Contributors

    • @AlessandroW made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/410
    • @CraigHutchinson made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/403

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.6...v0.36.0

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(34.37 KB)
    get_cpm.cmake(851 bytes)
  • v0.35.6(Sep 13, 2022)

    What's Changed

    • cpm_find_package Use found package version when possible by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/396
    • Expand absolute path later in get_cpm.cmake by @kisielk in https://github.com/cpm-cmake/CPM.cmake/pull/397
    • Don't warn about dirty source trees when a PATCH_COMMAND is provided by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/401

    New Contributors

    • @kisielk made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/397

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.5...v0.35.6

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(34.31 KB)
    get_cpm.cmake(851 bytes)
  • v0.35.5(Aug 11, 2022)

    What's Changed

    • Document policies being set to NEW when including CPM.cmake by @iboB in https://github.com/cpm-cmake/CPM.cmake/pull/383
    • Fix a very confusing typo (CMP.cmake -> CPM.cmake) by @OlivierLDff in https://github.com/cpm-cmake/CPM.cmake/pull/384
    • Perform policy changes only in top-level CPM.cmake script by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/386
    • Restore policy changes in CPMAddPackage by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/388

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.4...v0.35.5

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(34.15 KB)
    get_cpm.cmake(845 bytes)
  • v0.35.4(Aug 3, 2022)

    What's Changed

    • Add Methane Kit project to showcase table in ReadMe by @egorodet in https://github.com/cpm-cmake/CPM.cmake/pull/380
    • Use 3 column layout in showcase by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/381
    • Timestamps for URL downloads match the download time by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/372

    New Contributors

    • @egorodet made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/380

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.3...v0.35.4

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(34.05 KB)
    get_cpm.cmake(845 bytes)
  • v0.35.3(Jul 31, 2022)

  • v0.35.2(Jul 26, 2022)

    What's Changed

    • Add readme "Customize repository URL" with git-config by @OlivierLDff in https://github.com/cpm-cmake/CPM.cmake/pull/353
    • Klogg switched to CPM for dependency management by @variar in https://github.com/cpm-cmake/CPM.cmake/pull/363
    • bump example range-v3 to 0.12.0 by @david-fong in https://github.com/cpm-cmake/CPM.cmake/pull/366
    • CPMAddPackage fails if the SOURCE_DIR directory is deleted. by @thomas-mp in https://github.com/cpm-cmake/CPM.cmake/pull/370

    New Contributors

    • @variar made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/363
    • @david-fong made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/366
    • @thomas-mp made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/370

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.1...v0.35.2

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(33.77 KB)
    get_cpm.cmake(845 bytes)
  • v0.35.1(May 16, 2022)

    What's Changed

    • Add liblava to "Built with CPM.cmake" by @TheLavaBlock in https://github.com/cpm-cmake/CPM.cmake/pull/346
    • Allow overriding FetchContent using CPM by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/352

    New Contributors

    • @TheLavaBlock made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/346

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.35.0...v0.35.1

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(33.15 KB)
    get_cpm.cmake(845 bytes)
  • v0.35.0(Feb 11, 2022)

    What's Changed

    • Fix comment out-of-sync with modified code by @danra in https://github.com/cpm-cmake/CPM.cmake/pull/321
    • Unified GitHub workflow for tests on major operating systems by @iboB in https://github.com/cpm-cmake/CPM.cmake/pull/326
    • [Example] Disable JSON tests being included in ctest by @Vinpasso in https://github.com/cpm-cmake/CPM.cmake/pull/329
    • Remove badges from readme by @TheLartians in https://github.com/cpm-cmake/CPM.cmake/pull/327
    • Initial version of integration tests by @iboB in https://github.com/cpm-cmake/CPM.cmake/pull/330
    • Allows set/set(CACHE) to behave the same as set(X)/option(x) by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/335
    • Use CMake 3.14+ documented way to pass the source dir -S. by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/337
    • Fix beginner’s trap / fix broken example for nlohmann/json by @Tobi823 in https://github.com/cpm-cmake/CPM.cmake/pull/338
    • List of contributors by @iboB in https://github.com/cpm-cmake/CPM.cmake/pull/340
    • Some typo fixes. by @bilke in https://github.com/cpm-cmake/CPM.cmake/pull/341
    • Add per package CPM_DOWNLOAD controls by @robertmaynard in https://github.com/cpm-cmake/CPM.cmake/pull/336

    New Contributors

    • @danra made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/321
    • @Vinpasso made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/329
    • @robertmaynard made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/335
    • @Tobi823 made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/338
    • @bilke made their first contribution in https://github.com/cpm-cmake/CPM.cmake/pull/341

    Full Changelog: https://github.com/cpm-cmake/CPM.cmake/compare/v0.34.3...v0.35.0

    Thanks to everyone who contributed for these updates!

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(31.21 KB)
    get_cpm.cmake(845 bytes)
  • v0.34.3(Dec 30, 2021)

  • v0.34.2(Dec 15, 2021)

  • v0.34.1(Dec 5, 2021)

  • v0.34.0(Sep 15, 2021)

  • v0.33.0(Sep 15, 2021)

  • v0.32.3(Aug 29, 2021)

  • v0.32.2(Jun 8, 2021)

  • v0.32.1(Apr 16, 2021)

  • v0.32.0(Mar 25, 2021)

    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.

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(27.12 KB)
    get_cpm.cmake(845 bytes)
  • v0.31.2(Mar 25, 2021)

  • v0.31.1(Feb 23, 2021)

  • v0.31.0(Feb 22, 2021)

  • v0.30.0(Feb 17, 2021)

  • v0.29.0(Feb 16, 2021)

    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
    )
    
    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(21.31 KB)
    get_cpm.cmake(845 bytes)
  • v0.29.0-preview-4(Feb 15, 2021)

  • v0.29.0-preview-2(Feb 15, 2021)

  • v0.28.4(Feb 8, 2021)

  • v0.28.3(Feb 7, 2021)

  • v0.28.2(Jan 27, 2021)

    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!

    Source code(tar.gz)
    Source code(zip)
    CPM.cmake(20.63 KB)
    get_cpm.cmake(847 bytes)
  • v0.28.1(Jan 25, 2021)

  • v0.28.0(Jan 20, 2021)

Owner
CPM.cmake
CMake's missing package manager.
CPM.cmake
Template for reliable, cross-platform C++ project setup using cmake.

The C++ CMake Project Template cmake-init is a sophisticated copy & paste template for modern C and C++ projects. The main goals include support of al

CG Internals 811 Jan 3, 2023
CMake wrapper for Xrepo C and C++ package manager

xrepo-cmake CMake wrapper for Xrepo C and C++ package manager. Supporting the project Support this project by becoming a sponsor. Your logo will show

xmake-io 23 Nov 29, 2022
Autotools-style configure script wrapper around CMake

configure-cmake configure-cmake is an autotools-style configure script for CMake-based projects. People building software on Linux or BSD generally ex

Evan Nemerson 82 Dec 14, 2022
A CMake addon that avoids you writing boilerplate code for resource management.

SHader INJ(I)ector SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes s

Lorenzo Rutayisire 6 Dec 14, 2022
C package manager-ish

clib(1) Package manager for the C programming language. Installation Expects libcurl to be installed and linkable. With homebrew: $ brew install clib

clibs 4.5k Jan 6, 2023
C++ Package Manager

CPM Note CPM is not being actively maintained. I plan on keeping the website active but don't plan on making further modifications to the codebase. If

James 720 Dec 18, 2022
Examples of using Hunter package manager to build and run Android application.

Examples of using Hunter package manager to build and run Android application. Requirements Android NDK Go to download page and choose NDK for your pl

null 33 Oct 11, 2022
Enhanced CMake Project Manager plugin for Qt Creator

CMakeProjectManager2 Alternative CMake support for Qt Creator. Main differents from original CMakeProject plugin: Project file list readed from file s

Alexander Drozdov 71 Nov 20, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 65 Dec 6, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 395 Dec 24, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 163 Dec 5, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Nov 30, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 74 Dec 26, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Nov 2, 2022
A small c++ template with modern CMake

C++/CMake modern boilerplate This is a template for new projects, gives a good CMake base and a few dependencies you most likely want in your project.

Clément Grégoire 276 Jan 3, 2023
A versatile script engine abstraction layer.

ScriptX A versatile script engine abstraction layer ScriptX is a script engine abstraction layer. A variety of script engines are encapsulated on the

Tencent 382 Dec 22, 2022
C++ Library Manager for Windows, Linux, and MacOS

Vcpkg: Overview 中文总览 Español 한국어 Français Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constant

Microsoft 17.5k Jan 1, 2023