mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-25 05:37:28 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0370507fed | ||
|
|
c0855c9543 |
@@ -190,6 +190,9 @@ Note that passing the variable as a configure option to CMake will always overri
|
||||
|
||||
You can use `CPM_SOURCE_CACHE` on GitHub Actions workflows [cache](https://github.com/actions/cache) and combine it with ccache, to make your CI faster. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Caching-with-CPM.cmake-and-ccache-on-GitHub-Actions) for more info.
|
||||
|
||||
The directory where the version for a project is stored is by default the hash of the arguments to `CPMAddPackage()`.
|
||||
If for instance the patch command uses external files, the directory name can be set with the argument `CUSTOM_CACHE_KEY`.
|
||||
|
||||
### CPM_DOWNLOAD_ALL
|
||||
|
||||
If set, CPM will forward all calls to `CPMFindPackage` as `CPMAddPackage`.
|
||||
|
||||
@@ -534,6 +534,7 @@ function(CPMAddPackage)
|
||||
GIT_SHALLOW
|
||||
EXCLUDE_FROM_ALL
|
||||
SOURCE_SUBDIR
|
||||
CUSTOM_CACHE_KEY
|
||||
)
|
||||
|
||||
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
|
||||
@@ -704,7 +705,10 @@ function(CPMAddPackage)
|
||||
string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
|
||||
set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS})
|
||||
list(SORT origin_parameters)
|
||||
if(CPM_USE_NAMED_CACHE_DIRECTORIES)
|
||||
if(CPM_ARGS_CUSTOM_CACHE_KEY)
|
||||
# Application set a custom unique directory name
|
||||
set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${CPM_ARGS_CUSTOM_CACHE_KEY})
|
||||
elseif(CPM_USE_NAMED_CACHE_DIRECTORIES)
|
||||
string(SHA1 origin_hash "${origin_parameters};NEW_CACHE_STRUCTURE_TAG")
|
||||
set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}/${CPM_ARGS_NAME})
|
||||
else()
|
||||
|
||||
20
examples/xxHash/CMakeLists.txt
Normal file
20
examples/xxHash/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
project(CPMxxHashExample)
|
||||
|
||||
# ---- Dependencies ----
|
||||
|
||||
include(../../cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage(
|
||||
GITHUB_REPOSITORY Cyan4973/xxHash
|
||||
GIT_TAG v0.8.2
|
||||
OPTIONS "XXHASH_BUILD_ENABLE_INLINE_API OFF" "XXHASH_BUILD_XXHSUM OFF"
|
||||
SOURCE_SUBDIR cmake_unofficial
|
||||
)
|
||||
|
||||
# ---- Executable ----
|
||||
|
||||
add_executable(CPMxxHashExample main.cpp)
|
||||
target_compile_features(CPMxxHashExample PRIVATE cxx_std_17)
|
||||
target_link_libraries(CPMxxHashExample xxHash::xxhash)
|
||||
12
examples/xxHash/main.cpp
Normal file
12
examples/xxHash/main.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <xxh3.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::string example = "Hello World!";
|
||||
XXH64_hash_t hash = XXH3_64bits(example.data(), example.size());
|
||||
|
||||
std::cout << "Hash: " << hash << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -137,3 +137,19 @@ execute_process(
|
||||
|
||||
assert_equal(${ret} "0")
|
||||
assert_not_exists("${CPM_SOURCE_CACHE_DIR}/fibonacci")
|
||||
|
||||
# Use custom cache directory
|
||||
|
||||
set(FIBONACCI_PACKAGE_ARGS
|
||||
"CUSTOM_CACHE_KEY my_custom_unique_dir GIT_TAG e9ebf168ca0fffaa4ef8c6fefc6346aaa22f6ed5"
|
||||
)
|
||||
set(FIBONACCI_VERSION 1.1)
|
||||
update_cmake_lists()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E env "CPM_SOURCE_CACHE=${CPM_SOURCE_CACHE_DIR}" ${CMAKE_COMMAND}
|
||||
"-S${CMAKE_CURRENT_LIST_DIR}/remote_dependency" "-B${TEST_BUILD_DIR}" RESULT_VARIABLE ret
|
||||
)
|
||||
|
||||
assert_equal(${ret} "0")
|
||||
assert_exists("${CPM_SOURCE_CACHE_DIR}/fibonacci/my_custom_unique_dir")
|
||||
|
||||
Reference in New Issue
Block a user