Skip to content

Commit 91585e3

Browse files
authored
Added support for bitbucket repositories (#256)
* Added support for bitbucket repositories: * added variable BITBUCKET_REPOSITORY * added short syntax in form "bb:user/repo" * added description of that to readme.md * Added test for bitbucket short syntax * Used elseif syntax in handling of git services (github, gitlab, bitbucket). * Added HEMRND/TestingFramework example located on bitbucket.org * Reformatted CMakeLists.txt in TestingFramework example * Bumped version of TestingFramework. It supports older version of c++ standard. Co-authored-by: Paweł Gorgoń <[email protected]>
1 parent 9675d46 commit 91585e3

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CPMAddPackage("uri#tag")
5959
CPMAddPackage("uri@version#tag")
6060
```
6161

62-
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and coverted to `https://gitlab.com/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) flag.
62+
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and converted to `https://gitlab.com/user/name.git`. If the URI is of the form `bb:user/name`, it is interpreted as a [Bitbucket](https://bitbucket.org/) URI and converted to `https://bitbucket.org/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) flag.
6363

6464
The single-argument syntax also works for URLs:
6565

cmake/CPM.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ function(cpm_parse_add_package_single_arg arg outArgs)
302302
elseif(scheme STREQUAL "gl")
303303
set(out "GITLAB_REPOSITORY;${uri}")
304304
set(packageType "git")
305+
elseif(scheme STREQUAL "bb")
306+
set(out "BITBUCKET_REPOSITORY;${uri}")
307+
set(packageType "git")
305308
# A CPM-specific scheme was not found. Looks like this is a generic URL so try to determine
306309
# type
307310
elseif(arg MATCHES ".git/?(@|#|$)")
@@ -369,6 +372,7 @@ function(CPMAddPackage)
369372
DOWNLOAD_ONLY
370373
GITHUB_REPOSITORY
371374
GITLAB_REPOSITORY
375+
BITBUCKET_REPOSITORY
372376
GIT_REPOSITORY
373377
SOURCE_DIR
374378
DOWNLOAD_COMMAND
@@ -399,10 +403,10 @@ function(CPMAddPackage)
399403

400404
if(DEFINED CPM_ARGS_GITHUB_REPOSITORY)
401405
set(CPM_ARGS_GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git")
402-
endif()
403-
404-
if(DEFINED CPM_ARGS_GITLAB_REPOSITORY)
406+
elseif(DEFINED CPM_ARGS_GITLAB_REPOSITORY)
405407
set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git")
408+
elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY)
409+
set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git")
406410
endif()
407411

408412
if(DEFINED CPM_ARGS_GIT_REPOSITORY)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
2+
3+
project(CPMTestingFrameworkExample)
4+
5+
include(../../cmake/CPM.cmake)
6+
CPMAddPackage("bb:HEMRND/[email protected]")
7+
add_test_suites(TESTS SomeTest)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <HEM/TestingFramework.hpp>
2+
3+
using namespace fakeit;
4+
5+
class ITest {
6+
public:
7+
virtual int getInt() = 0;
8+
};
9+
10+
TEST_CASE("Testing Framework Test") {
11+
constexpr int someIntValue = 123456;
12+
13+
Mock<ITest> testMock;
14+
When(Method(testMock, getInt)).Return(someIntValue);
15+
16+
int readValue = testMock.get().getInt();
17+
18+
REQUIRE(readValue == someIntValue);
19+
}

test/unit/parse_add_package_single_arg.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ assert_equal("GITLAB_REPOSITORY;foo/bar" "${args}")
3030
cpm_parse_add_package_single_arg("gl:foo/Bar" args)
3131
assert_equal("GITLAB_REPOSITORY;foo/Bar" "${args}")
3232

33+
cpm_parse_add_package_single_arg("bb:foo/bar" args)
34+
assert_equal("BITBUCKET_REPOSITORY;foo/bar" "${args}")
35+
36+
cpm_parse_add_package_single_arg("bb:foo/Bar" args)
37+
assert_equal("BITBUCKET_REPOSITORY;foo/Bar" "${args}")
38+
3339
cpm_parse_add_package_single_arg("https://github.com/cpm-cmake/[email protected]" args)
3440
assert_equal("GIT_REPOSITORY;https://github.com/cpm-cmake/CPM.cmake.git;VERSION;0.30.5" "${args}")
3541

0 commit comments

Comments
 (0)