forked from conan-io/conan
/
test_weird_library_names.py
116 lines (95 loc) · 3.79 KB
/
test_weird_library_names.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import textwrap
import pytest
from conans.test.assets.cmake import gen_cmakelists
from conans.test.assets.pkg_cmake import pkg_cmake
from conans.test.assets.sources import gen_function_h, gen_function_cpp
from conans.test.utils.tools import TestClient
@pytest.fixture(scope="module")
def client_weird_lib_name():
c = TestClient()
conanfile = textwrap.dedent("""
import os, platform
from conans import ConanFile
from conan.tools.cmake import CMake
from conan.tools.layout import cmake_layout
class Pkg(ConanFile):
exports_sources = "CMakeLists.txt", "src/*"
settings = "os", "compiler", "arch", "build_type"
generators = "CMakeToolchain", "CMakeDeps"
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
self.copy("*.h", dst="include", src="src")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
ext = "a" if platform.system() != "Windows" else "lib"
prefix = "lib" if platform.system() != "Windows" else ""
os.chdir(os.path.join(self.package_folder, "lib"))
os.rename("{}hello_0.1.{}".format(prefix, ext),
"{}he!llo@0.1.{}".format(prefix, ext))
def package_info(self):
self.cpp_info.libs = ["he!llo@0.1"]
""")
hdr = gen_function_h(name="hello")
src = gen_function_cpp(name="hello")
cmake = gen_cmakelists(libname="hello_0.1", libsources=["src/hello.cpp"])
c.save({"src/hello.h": hdr,
"src/hello.cpp": src,
"CMakeLists.txt": cmake,
"conanfile.py": conanfile})
c.run("create . hello/0.1@")
return c
@pytest.mark.tool_cmake
def test_cmakedeps(client_weird_lib_name):
c = client_weird_lib_name
c.save(pkg_cmake("chat", "0.1", requires=["hello/0.1"]), clean_first=True)
c.run("create . chat/0.1@")
assert "chat/0.1: Created package" in c.out
# TODO: Remove in Conan 2.0
@pytest.mark.tool_cmake
def test_cmake_find_package(client_weird_lib_name):
c = client_weird_lib_name
files = pkg_cmake("chat", "0.1", requires=["hello/0.1"])
conanfile = textwrap.dedent("""
import os, platform
from conans import ConanFile, CMake
class Pkg(ConanFile):
exports_sources = "CMakeLists.txt", "src/*"
settings = "os", "compiler", "arch", "build_type"
generators = "cmake_find_package"
requires = "hello/0.1"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
""")
files["conanfile.py"] = conanfile
c.save(files, clean_first=True)
c.run("create . chat/0.1@")
assert "chat/0.1: Created package" in c.out
# TODO: Remove in Conan 2.0
@pytest.mark.tool_cmake
def test_cmake_find_package_multi(client_weird_lib_name):
c = client_weird_lib_name
files = pkg_cmake("chat", "0.1", requires=["hello/0.1"])
conanfile = textwrap.dedent("""
import os, platform
from conans import ConanFile, CMake
class Pkg(ConanFile):
exports_sources = "CMakeLists.txt", "src/*"
settings = "os", "compiler", "arch", "build_type"
generators = "cmake_find_package_multi"
requires = "hello/0.1"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
""")
files["conanfile.py"] = conanfile
c.save(files, clean_first=True)
c.run("create . chat/0.1@")
assert "chat/0.1: Created package" in c.out