mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-21 19:57:24 -05:00
If a name isn't provided, try to infer it from the git repo (#202)
* Added assert_not_defined check * Function to get package name form git uri and tests * Autofix format * If name is not provided, try to infer it from the git repo * Unset result of cpm_package_name_from_git_uri if there is no match - Also reordered tests to ensure that the result is actually unset when needed * Removed trailing spaces in README * Updated the main example with the new minimal syntax * Well... autofix format again * Update error message for missing name to reflect the possible auto-infer step * Autofix format... yet again :)
This commit is contained in:
committed by
GitHub
parent
2744b87f07
commit
4cbf443363
28
test/unit/package_name_from_git_uri.cmake
Normal file
28
test/unit/package_name_from_git_uri.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
include(${CPM_PATH}/CPM.cmake)
|
||||
include(${CPM_PATH}/testing.cmake)
|
||||
|
||||
cpm_package_name_from_git_uri("https://github.com/cpm-cmake/CPM.cmake.git" name)
|
||||
assert_equal("CPM.cmake" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("ssh://user@host.xz:123/path/to/pkg.git/" name)
|
||||
assert_equal("pkg" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("git://host.xz/path/to/pkg.git" name)
|
||||
assert_equal("pkg" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("git@host.xz:cool-pkg.git" name)
|
||||
assert_equal("cool-pkg" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("file:///path/to/pkg33.git" name)
|
||||
assert_equal("pkg33" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("../local-repo/.git" name)
|
||||
assert_equal("local-repo" ${name})
|
||||
|
||||
cpm_package_name_from_git_uri("asdf" name)
|
||||
assert_not_defined(name)
|
||||
|
||||
cpm_package_name_from_git_uri("/something.git/stuff" name)
|
||||
assert_not_defined(name)
|
||||
Reference in New Issue
Block a user