Skip to content

Commit

Permalink
Apply formatting rules (cpm-cmake#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-channon-PA committed Jun 17, 2024
1 parent 2cfef09 commit 4d89e91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
34 changes: 15 additions & 19 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ set(CPM_URI_SCHEME_PATTERN

function(
cpm_uri_scheme_from_string

# INPUTS
schemeStr

# OUTPUTS
alias
longName
Expand Down Expand Up @@ -387,8 +385,8 @@ endfunction()
function(cpm_infer_package_type uri uriType uriSuffix packageType)
if("${uriType}" STREQUAL "GIT_REPOSITORY")
set(${packageType}
"git"
PARENT_SCOPE
"git"
PARENT_SCOPE
)
else()
if("${uri}" MATCHES ".git([@#$]?)")
Expand All @@ -399,8 +397,8 @@ function(cpm_infer_package_type uri uriType uriSuffix packageType)
else()
if("${uriSuffix}" MATCHES ".git([@#$]?)")
set(${packageType}
"git"
PARENT_SCOPE
"git"
PARENT_SCOPE
)
else()
set(${packageType}
Expand Down Expand Up @@ -515,12 +513,7 @@ function(cpm_parse_add_package_single_arg arg outArgs)
cpm_extract_scheme(${arg} scheme uriFragment isScheme)
if(isScheme)
cpm_expand_via_scheme(
${scheme}
${uriFragment}
outputVar
repoType
packageType
successfulExpansion
${scheme} ${uriFragment} outputVar repoType packageType successfulExpansion
)
if(successfulExpansion)
set(out "${outputVar}")
Expand Down Expand Up @@ -757,7 +750,15 @@ function(CPMAddPackage)
)

foreach(scheme ${CPM_URI_SCHEMES})
cpm_uri_scheme_from_string(${scheme} alias longName uriType uriRoot uriSuffix isScheme)
cpm_uri_scheme_from_string(
${scheme}
alias
longName
uriType
uriRoot
uriSuffix
isScheme
)
list(APPEND oneValueArgs ${longName})
endforeach()

Expand All @@ -784,12 +785,7 @@ function(CPMAddPackage)
if(DEFINED CPM_ARGS_${longName})
string(CONCAT cpmRepoType CPM_ARGS_ ${longName})
cpm_expand_via_scheme(
${alias}
${${cpmRepoType}}
completeUri
repoType
pkgType
successfulExpansion
${alias} ${${cpmRepoType}} completeUri repoType pkgType successfulExpansion
)
if(NOT successfulExpansion)
message(FATAL_ERROR "${CPM_INDENT} Failed to generate repository URL from '${cpmRepoType}'")
Expand Down
19 changes: 4 additions & 15 deletions test/unit/parse_add_package_single_arg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ cpm_parse_add_package_single_arg("gh:cpm-cmake/[email protected]" args)
assert_equal("GITHUB_REPOSITORY;cpm-cmake/CPM.cmake;VERSION;1.2.3" "${args}")

cpm_parse_add_package_single_arg("gh:cpm-cmake/CPM.cmake#master" args)
assert_equal(
"GITHUB_REPOSITORY;cpm-cmake/CPM.cmake;GIT_TAG;master" "${args}"
)
assert_equal("GITHUB_REPOSITORY;cpm-cmake/CPM.cmake;GIT_TAG;master" "${args}")

cpm_parse_add_package_single_arg("gh:cpm-cmake/[email protected]#asdf" args)
assert_equal(
"GITHUB_REPOSITORY;cpm-cmake/CPM.cmake;VERSION;0.20.3;GIT_TAG;asdf"
"${args}"
)
assert_equal("GITHUB_REPOSITORY;cpm-cmake/CPM.cmake;VERSION;0.20.3;GIT_TAG;asdf" "${args}")

cpm_parse_add_package_single_arg("gh:a/b#c@d" args)
assert_equal("GITHUB_REPOSITORY;a/b;GIT_TAG;c;VERSION;d" "${args}")
Expand Down Expand Up @@ -86,16 +81,10 @@ cpmdefineurischeme(
)

cpm_parse_add_package_single_arg("ir:somegroup/[email protected]#asdf" args)
assert_equal(
"INTERNAL_REPOS;somegroup/somerepo;VERSION;0.20.3;GIT_TAG;asdf"
"${args}"
)
assert_equal("INTERNAL_REPOS;somegroup/somerepo;VERSION;0.20.3;GIT_TAG;asdf" "${args}")

cpm_parse_add_package_single_arg("ir2:somegroup/[email protected]#asdf" args)
assert_equal(
"INTERNAL_REPOS2;somegroup/somerepo;VERSION;0.20.3;GIT_TAG;asdf"
"${args}"
)
assert_equal("INTERNAL_REPOS2;somegroup/somerepo;VERSION;0.20.3;GIT_TAG;asdf" "${args}")

cpm_parse_add_package_single_arg("af:somegroup/someitem.zip" args)
assert_equal("ARTIFACTORY_PKG;somegroup/someitem.zip" "${args}")
Expand Down

0 comments on commit 4d89e91

Please sign in to comment.