Skip to main content

Custom Cmake Package Manager - Trying to bring 'npm' and 'pip' vibes to C++ (or any cmake project)

Project description

📦 CCPM - Custom Cmake Package Manager

CCPM Logo

🧑‍💻 Are you tired of watching time fade away as CMake recompiles Assimp for the sixth time today just because you had to do a rebuild of your own code?

🖖 Do you have your CMakeLists.txt full of add_subdirectory for code that is not yours?

add_subdirectory(third_party/fmt)
find_package(fmt REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)

No worries, we’ve got the solution right here!

🌊 Flow

🚀 Install the tool

pip install ccpm

📃 Define your dependencies

The below example will install fmt, glfw and glm with custom defines.

Create a simple ccpm.toml in the same folder of main 'CMakeLists.txt' similar to this one:

[[git]]
repo_url = "https://github.com/fmtlib/fmt"
tag = "11.0.2"
defines = ["FMT_TEST=OFF", "FMT_DOC=OFF"]

[[git]]
repo_url = "https://github.com/glfw/glfw"
tag = "3.4"
defines = ["GLFW_BUILD_DOCS=OFF", "GLFW_BUILD_TESTS=OFF", "GLFW_BUILD_EXAMPLES=OFF"]

[[git]]
repo_url = "https://github.com/g-truc/glm"
tag = "1.0.1"
defines = ["GLM_BUILD_TESTS=OFF", "GLM_ENABLE_CXX_20=ON"]

✍️ On your CMake

include(${CMAKE_SOURCE_DIR}/.ccpm/ccpm.cmake)  # This resolves modulepaths
add_executable(${AWESOME_TARGET} main.cpp)

# I'm working on simplify this stage but there is many differences between some packages
find_packge(fmt REQUIRED)
target_link_libraries(${AWESOME_TARGET} PRIVATE fmt::fmt)

# Goal syntax
include(${CMAKE_SOURCE_DIR}/.ccpm/ccpm.cmake)  # This will include the 'find_packge(fmt REQUIRED)'
target_link_libraries(${AWESOME_TARGET} PRIVATE ${CCPM_LINK_LIBRARIES})  # To include all of them
target_link_libraries(${AWESOME_TARGET} PRIVATE ${CCPM_LIB_fmt})         # For more granularity

🛠️ Donwload, Build and Install packages

ccpm -i   # To run download+build+install process (only needed if you change the .toml file)
ccpm -b   # Builds the main 'CMakeLists.txt' (by default in debug, add -r for release)

📝 Notes

This script assumes that you have the following commands installed:

  • cmake
  • git

In the roadmap:

  • Other git providers [^1]
  • Add option to choose CMake Generator
  • Automatic lib name and target gathering [^2]
  • Zip files
  • Others VCS like SVN or Hg

Lectures / Inspiration:

[^1]: The first iteration was github only. [^2]: For cases like glfw where its find_package is glfw3 and its link_library is just glfw instead of glfw::glfw like the vast majority of the packages.

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

ccpm-0.0.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

ccpm-0.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file ccpm-0.0.1.tar.gz.

File metadata

  • Download URL: ccpm-0.0.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ccpm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d01aa728230f6f56db1c6b109e121ee66f37477de54d5ab1546024db5612ada2
MD5 2e675635b3574afd8fedb45f11853559
BLAKE2b-256 6856ee5a44c75c886841507a0ceae18a72d7c05de5e5fa275d73771d0b4da1bf

See more details on using hashes here.

File details

Details for the file ccpm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ccpm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ccpm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3690704e7983f1bb39c47f3de33fc90e0f11ca936ba688d43826ac529fcb5429
MD5 57bc834b147363f2310544c14bd904bf
BLAKE2b-256 3f6dc1cdd46ad23a08a3c49342b4fbe0e6def188a8ca53c0b888574ba0c31c3a

See more details on using hashes here.

Supported by

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