mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-24 05:08:01 -05:00
Treat relative paths as relative to parent project's remote (#522)
* Treat relative paths as relative to parent project's remote * replace unit test case with integration test * run relative URL test only on supported CMake versions (3.27) * omit cmake 2.25.x test runner as replaced by 2.27.x --------- Co-authored-by: Chris Wright <chris.wright@mqa.co.uk> Co-authored-by: Lars Melchior <lars.melchior@gmail.com>
This commit is contained in:
2
.github/workflows/style.yaml
vendored
2
.github/workflows/style.yaml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: Setup cmake
|
- name: Setup cmake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.13
|
uses: jwlawson/actions-setup-cmake@v1.13
|
||||||
with:
|
with:
|
||||||
cmake-version: '3.25.x'
|
cmake-version: '3.27.x'
|
||||||
|
|
||||||
- name: Install format dependencies
|
- name: Install format dependencies
|
||||||
run: pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml
|
run: pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml
|
||||||
|
|||||||
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-2022, macos-latest]
|
os: [ubuntu-latest, windows-2022, macos-latest]
|
||||||
# we want to ensure compatibility with a recent CMake version as well as the lowest officially supported
|
# we want to ensure compatibility with a recent CMake version as well as the lowest officially supported
|
||||||
# legacy version that we define as the default version of the second-latest Ubuntu LTS release currently available
|
# legacy version that we define as the default version of the second-latest Ubuntu LTS release currently available
|
||||||
cmake_version: ['3.16.3', '3.25.1']
|
cmake_version: ['3.16.3', '3.27.5']
|
||||||
exclude:
|
exclude:
|
||||||
# there seems to be an issue with CMake 3.16 not finding a C++ compiler on windows-2022
|
# there seems to be an issue with CMake 3.16 not finding a C++ compiler on windows-2022
|
||||||
- os: windows-2022
|
- os: windows-2022
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ Dependencies using CPM will automatically use the updated script of the outermos
|
|||||||
- **Some CMake policies set to `NEW`** Including CPM.cmake will lead to several CMake policies being set to `NEW`. Users which need the old behavior will need to manually modify their CMake code to ensure they're set to `OLD` at the appropriate places. The policies are:
|
- **Some CMake policies set to `NEW`** Including CPM.cmake will lead to several CMake policies being set to `NEW`. Users which need the old behavior will need to manually modify their CMake code to ensure they're set to `OLD` at the appropriate places. The policies are:
|
||||||
- [CMP0077](https://cmake.org/cmake/help/latest/policy/CMP0077.html) and [CMP0126](https://cmake.org/cmake/help/latest/policy/CMP0126.html). They make setting package options from `CMPAddPackage` possible.
|
- [CMP0077](https://cmake.org/cmake/help/latest/policy/CMP0077.html) and [CMP0126](https://cmake.org/cmake/help/latest/policy/CMP0126.html). They make setting package options from `CMPAddPackage` possible.
|
||||||
- [CMP0135](https://cmake.org/cmake/help/latest/policy/CMP0135.html) It allows for proper package rebuilds of packages which are archives, source cache is not used, and the package URL is changed to an older version.
|
- [CMP0135](https://cmake.org/cmake/help/latest/policy/CMP0135.html) It allows for proper package rebuilds of packages which are archives, source cache is not used, and the package URL is changed to an older version.
|
||||||
|
- [CMP0150](https://cmake.org/cmake/help/latest/policy/CMP0150.html) Relative paths provided to `GIT_REPOSITORY` are treated as relative to the parent project's remote.
|
||||||
|
|
||||||
For projects with more complex needs and where an extra setup step doesn't matter, it may be worth to check out an external C++ package manager such as [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://conan.io) or [hunter](https://github.com/ruslo/hunter).
|
For projects with more complex needs and where an extra setup step doesn't matter, it may be worth to check out an external C++ package manager such as [vcpkg](https://github.com/microsoft/vcpkg), [conan](https://conan.io) or [hunter](https://github.com/ruslo/hunter).
|
||||||
Dependencies added with `CPMFindPackage` should work with external package managers.
|
Dependencies added with `CPMFindPackage` should work with external package managers.
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ macro(cpm_set_policies)
|
|||||||
cmake_policy(SET CMP0135 NEW)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
|
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# treat relative git repository paths as being relative to the parent project's remote
|
||||||
|
if(POLICY CMP0150)
|
||||||
|
cmake_policy(SET CMP0150 NEW)
|
||||||
|
set(CMAKE_POLICY_DEFAULT_CMP0150 NEW)
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
cpm_set_policies()
|
cpm_set_policies()
|
||||||
|
|
||||||
|
|||||||
17
test/integration/test_relative_urls.rb
Normal file
17
test/integration/test_relative_urls.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
require_relative './lib'
|
||||||
|
|
||||||
|
class RelativeURLs < IntegrationTest
|
||||||
|
def setup
|
||||||
|
# relative URLs were introduced in CMake 3.27
|
||||||
|
@relative_urls_supported = (!ENV['CMAKE_VERSION']) || (Gem::Version.new(ENV['CMAKE_VERSION']) >= Gem::Version.new('3.27'))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_add_project_with_relative_urls
|
||||||
|
omit_if !@relative_urls_supported do
|
||||||
|
prj = make_project from_template: 'using-fibadder'
|
||||||
|
prj.create_lists_from_default_template package: 'CPMAddPackage("gh:cpm-cmake/testpack-fibadder@1.1.0-relative-urls")'
|
||||||
|
assert_success prj.configure
|
||||||
|
assert_success prj.build
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user