/
test_cmakedeps.py
64 lines (53 loc) · 2.92 KB
/
test_cmakedeps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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())
conanfile.settings.build_type = "Release"
conanfile.settings.arch = "x86"
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"]
assert "set(MySuperPkg1_INCLUDE_DIRS_RELEASE )" in files["ComplexFileName1-release-x86-data.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", "Debug"],
"arch": ["x86", "x64"]}), EnvValues())
conanfile.settings.build_type = "Debug"
conanfile.settings.arch = "x64"
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"]
assert "set(GlobakPkgName1_INCLUDE_DIRS_DEBUG )" in files["ComplexFileName1-debug-x64-data.cmake"]
assert "set(GlobakPkgName1_MySuperPkg1_INCLUDE_DIRS_DEBUG )" in files["ComplexFileName1-debug-x64-data.cmake"]
with pytest.raises(ConanException,
match="'mypkg' defines information for 'cmake_find_package_multi'"):
with environment_append({CONAN_V2_MODE_ENVVAR: "1"}):
_ = cmakedeps.content