-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preparing migration of names to CMakeDeps (#8568)
* preparing migration of names to CMakeDeps * moving the workaround to CMakeDeps * review
- Loading branch information
1 parent
40aa789
commit 4660d80
Showing
2 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import pytest | ||
from mock import Mock | ||
|
||
from conan.tools.cmake import CMakeDeps | ||
from conans import ConanFile, Settings | ||
from conans.client.tools import environment_append | ||
from conans.errors import ConanException | ||
from conans.model.build_info import CppInfo, DepCppInfo | ||
from conans.model.env_info import EnvValues | ||
from conans.util.conan_v2_mode import CONAN_V2_MODE_ENVVAR | ||
|
||
|
||
def test_cpp_info_name_cmakedeps(): | ||
conanfile = ConanFile(Mock(), None) | ||
conanfile.settings = "os", "compiler", "build_type", "arch" | ||
conanfile.initialize(Settings({"os": ["Windows"], | ||
"compiler": ["gcc"], | ||
"build_type": ["Release"], | ||
"arch": ["x86"]}), EnvValues()) | ||
|
||
cpp_info = CppInfo("mypkg", "dummy_root_folder1") | ||
cpp_info.names["cmake_find_package_multi"] = "MySuperPkg1" | ||
cpp_info.filenames["cmake_find_package_multi"] = "ComplexFileName1" | ||
conanfile.deps_cpp_info.add("mypkg", cpp_info) | ||
|
||
cmakedeps = CMakeDeps(conanfile) | ||
files = cmakedeps.content | ||
assert "TARGET MySuperPkg1::MySuperPkg1" in files["ComplexFileName1Config.cmake"] | ||
|
||
with pytest.raises(ConanException, | ||
match="'mypkg' defines information for 'cmake_find_package_multi'"): | ||
with environment_append({CONAN_V2_MODE_ENVVAR: "1"}): | ||
_ = cmakedeps.content | ||
|
||
|
||
def test_cpp_info_name_cmakedeps_components(): | ||
conanfile = ConanFile(Mock(), None) | ||
conanfile.settings = "os", "compiler", "build_type", "arch" | ||
conanfile.initialize(Settings({"os": ["Windows"], | ||
"compiler": ["gcc"], | ||
"build_type": ["Release"], | ||
"arch": ["x86"]}), EnvValues()) | ||
|
||
cpp_info = CppInfo("mypkg", "dummy_root_folder1") | ||
cpp_info.names["cmake_find_package_multi"] = "GlobakPkgName1" | ||
cpp_info.components["mycomp"].names["cmake_find_package_multi"] = "MySuperPkg1" | ||
cpp_info.filenames["cmake_find_package_multi"] = "ComplexFileName1" | ||
conanfile.deps_cpp_info.add("mypkg", DepCppInfo(cpp_info)) | ||
|
||
cmakedeps = CMakeDeps(conanfile) | ||
files = cmakedeps.content | ||
assert "TARGET GlobakPkgName1::MySuperPkg1" in files["ComplexFileName1Config.cmake"] | ||
|
||
with pytest.raises(ConanException, | ||
match="'mypkg' defines information for 'cmake_find_package_multi'"): | ||
with environment_append({CONAN_V2_MODE_ENVVAR: "1"}): | ||
_ = cmakedeps.content |