{"id":13831756,"url":"https://github.com/pfultz2/cmake-get","last_synced_at":"2025-04-12T12:31:45.499Z","repository":{"id":143674658,"uuid":"86213564","full_name":"pfultz2/cmake-get","owner":"pfultz2","description":"Get dependencies with cmake","archived":false,"fork":false,"pushed_at":"2019-01-18T23:37:40.000Z","size":43,"stargazers_count":63,"open_issues_count":3,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T07:11:17.885Z","etag":null,"topics":["c","cget","cmake","cmake-modules","cmake-packages","cplusplus","cpp","cross-platform","dependency-manager","linux","osx","package-manager","windows"],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfultz2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-26T06:52:25.000Z","updated_at":"2024-01-05T00:19:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c18400c-ba78-4061-b0fd-1ce1d55aa8f5","html_url":"https://github.com/pfultz2/cmake-get","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fcmake-get","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fcmake-get/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fcmake-get/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fcmake-get/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfultz2","download_url":"https://codeload.github.com/pfultz2/cmake-get/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566536,"owners_count":21125681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cget","cmake","cmake-modules","cmake-packages","cplusplus","cpp","cross-platform","dependency-manager","linux","osx","package-manager","windows"],"created_at":"2024-08-04T10:01:39.185Z","updated_at":"2025-04-12T12:31:44.853Z","avatar_url":"https://github.com/pfultz2.png","language":"CMake","readme":"cmake-get\n=========\n\nA cmake module to get dependencies. This module can be used in config mode or in script mode.\n\nInstallation\n============\n\nThe module is just one file 'CMakeGet.cmake' which can be copied into your project and then included. It can also be installed with cmake:\n\n    mkdir build\n    cd build\n    cmake ..\n    cmake --build . --target install\n\nAnd then it can be used with `find_package(CMakeGet)`.\n\n\nConfig mode\n===========\n\nIn config mode, this is similiar to cmake's `ExternalProject` with some differences:\n\n* Dependencies are installed during cmake configuration instead of during build. This avoids the need of writing super build projects as cmake's `find_*` commands can be used to find the dependencies all in the same build project.\n* Non-cmake build steps can be put in a [recipe](http://cget.readthedocs.io/en/latest/src/recipe.html#structure-of-a-recipe) that can be shared and re-used by many users, instead of rewriting the build steps for every projects.\n* A `BUILD_DEPS` variable is provided to enable the installation of dependencies(it defaults to OFF). This allows dependencies to be disabled for when a user wants to use a package manager to install the dependencies, but then can be enabled when the user doesn't want to use a package manager.\n\n\nTo setup with cmake, first list the dependecies in a [requirements.txt file](http://cget.readthedocs.io/en/latest/src/requirements.html) and the add something like this to cmake:\n\n    cmake_get_from(requirements.txt PREFIX ${CMAKE_CURRENT_BINARY_DIR}/deps)\n    list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/deps)\n\nAlso, if recipes are used, its best not to list them in the [requirements.txt file](http://cget.readthedocs.io/en/latest/src/requirements.html). Instead just install them in the cmake itself:\n\n    cmake_get(pfultz2/cget-recipes PREFIX ${CMAKE_CURRENT_BINARY_DIR}/deps)\n    cmake_get_from(requirements.txt PREFIX ${CMAKE_CURRENT_BINARY_DIR}/deps)\n    list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/deps)\n\nOf course, this still has the same weakness as `ExternalProject` as the toolchain is not transitive. \n\nScript mode\n===========\n\nScript mode enables the ability to write a cmake script to install a dependency. This can help with toolchain transitivity as the user can invoke the script with all the same cmake settings. The disadvantage is that the user has an extra step to install dependencies. For example, a script 'dependencies.cmake' like this could be made to install dependencies from a 'requirements.txt':\n\n    #!/usr/bin/env cmake -P\n\n    set(ARGS)\n    foreach(i RANGE 4 ${CMAKE_ARGC})\n        list(APPEND ARGS ${CMAKE_ARGV${i}})\n    endforeach()\n\n    set(_PREFIX ${CMAKE_ARGV3})\n\n    # Make sure this is in the module path\n    list(APPEND CMAKE_MODULE_PATH ${CMAKEGET_MODULE_PATH})\n    include(CMakeGet)\n\n    get_filename_component(PREFIX ${_PREFIX} ABSOLUTE)\n    # Install recipes\n    cmake_get(pfultz2/cget-recipes PREFIX ${PREFIX} CMAKE_ARGS ${ARGS})\n    cmake_get_from(requirements.txt PREFIX ${PREFIX} CMAKE_ARGS ${ARGS})\n\nSo then the user would run this instead:\n\n    ./dependencies.cmake deps/\n    mkdir build\n    cd build\n    cmake -DCMAKE_PREFIX_PATH=../deps/ ..\n\n\nReference\n=========\n\ncmake_get\n---------\n\n    cmake_get(\u003cpkg\u003e\n        [PREFIX \u003cprefix\u003e]\n        [HASH \u003chash\u003e]\n        [CMAKE_FILE \u003ccmake-file\u003e]\n        [CMAKE_ARGS \u003cargs\u003e...]\n    )\n\nThis will install a cmake package. It will run something equivalent to this in order to install the package:\n\n    mkdir build\n    cd build\n    cmake .. -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${CMAKE_ARGS}\n    cmake --build .\n    cmake --build . --target install\n\n* `\u003cpkg\u003e`\u003cbr\u003e\nThis is the package to be installed as described [here](http://cget.readthedocs.io/en/latest/src/package_src.html). It can be a URL or even a [recipe](http://cget.readthedocs.io/en/latest/src/recipe.html).\n* `PREFIX \u003cprefix\u003e`\u003cbr\u003e\nThis is prefix to where the package will be installed.\n* `HASH \u003chash\u003e`\u003cbr\u003e\nThis is a checksum hash that will be checked on a package.\n* `CMAKE_FILE \u003ccmake-file\u003e`\u003cbr\u003e\nThis is a cmake file that will be used to build the package. This is useful for a package that does not provide a cmake file already.\n* `CMAKE_ARGS \u003cargs\u003e...`\u003cbr\u003e\nThis is additional cmake arguments that are passed to the configuration step.\n\ncmake_get_from\n--------------\n\n    cmake_get_from(\u003cfilename\u003e\n        [PREFIX \u003cprefix\u003e]\n        [CMAKE_ARGS \u003cargs\u003e...]\n    )\n\nThis will install a list of packages stored in a file.\n\n* `\u003cfilename\u003e`\u003cbr\u003e\nThis a file that will list packages to be installed, The format of the file is described [here](http://cget.readthedocs.io/en/latest/src/requirements.html).\n* `PREFIX \u003cprefix\u003e`\u003cbr\u003e\nThis is prefix to where the package will be installed.\n* `CMAKE_ARGS \u003cargs\u003e...`\u003cbr\u003e\nThis is additional cmake arguments that are passed to the configuration step.\n","funding_links":[],"categories":["CMake","Utility Scripts"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fcmake-get","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfultz2%2Fcmake-get","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fcmake-get/lists"}