@@ -30,9 +30,6 @@ class PkgConan(ConanFile):
30
30
requires = "lib/1.0"
31
31
settings = "os", "arch", "compiler", "build_type"
32
32
generators = "CMakeDeps"
33
- def build(self):
34
- cmake = CMake(self)
35
- cmake.configure()
36
33
""" )
37
34
c .save ({"conanfile.py" : conanfile }, clean_first = True )
38
35
c .run (f"install . -c tools.cmake.cmakedeps:new={ new_value } " )
@@ -76,25 +73,81 @@ def package_info(self):
76
73
c .run ("create ." )
77
74
conanfile = textwrap .dedent (f"""
78
75
from conan import ConanFile
79
- from conan.tools.cmake import CMake
80
76
class PkgConan(ConanFile):
81
77
requires = "libb/1.0"
82
78
settings = "os", "arch", "compiler", "build_type"
83
79
generators = "CMakeDeps"
84
- def build(self):
85
- cmake = CMake(self)
86
- cmake.configure()
87
80
""" )
88
81
c .save ({"conanfile.py" : conanfile }, clean_first = True )
89
82
c .run (f"install . -c tools.cmake.cmakedeps:new={ new_value } " )
90
83
cmake_paths = c .load ("conan_cmakedeps_paths.cmake" )
91
- cmake_paths .replace ("\\ " , "/" )
92
84
assert re .search (r"list\(PREPEND CMAKE_PROGRAM_PATH \".*/libb.*/p/binb\"\)" , cmake_paths )
93
85
assert not re .search (r"list\(PREPEND CMAKE_PROGRAM_PATH /bina\"" , cmake_paths )
94
86
assert re .search (r"list\(PREPEND CMAKE_LIBRARY_PATH \".*/libb.*/p/libb\" \".*/liba.*/p/liba\"\)" , cmake_paths )
95
87
assert re .search (r"list\(PREPEND CMAKE_INCLUDE_PATH \".*/libb.*/p/includeb\" \".*/liba.*/p/includea\"\)" , cmake_paths )
96
88
97
89
90
+ def test_cmakedeps_deployer_relative_paths ():
91
+ c = TestClient ()
92
+ conanfile = textwrap .dedent ("""
93
+ import os
94
+ from conan.tools.files import copy
95
+ from conan import ConanFile
96
+ class TestConan(ConanFile):
97
+ name = "liba"
98
+ version = "1.0"
99
+
100
+ def package_info(self):
101
+ self.cpp_info.includedirs = ["includea"]
102
+ self.cpp_info.libdirs = ["bina"]
103
+ self.cpp_info.bindirs = ["bina"]
104
+ crypto_module = os.path.join("share", "cmake", "crypto.cmake")
105
+ self.cpp_info.set_property("cmake_build_modules", [crypto_module])
106
+ """ )
107
+ c .save ({"conanfile.py" : conanfile })
108
+ c .run ("create ." )
109
+
110
+ conanfile_cmake = textwrap .dedent ("""
111
+ import os
112
+ from conan.tools.files import save
113
+ from conan import ConanFile
114
+ class TestConan(ConanFile):
115
+ name = "libb"
116
+ version = "1.0"
117
+
118
+ def package(self):
119
+ save(self, os.path.join(self.package_folder, "libb-config.cmake"), "")
120
+ def package_info(self):
121
+ self.cpp_info.set_property("cmake_find_mode", "none")
122
+ """ )
123
+
124
+ c .save ({"conanfile.py" : conanfile_cmake })
125
+ c .run ("create ." )
126
+ conanfile = textwrap .dedent (f"""
127
+ from conan import ConanFile
128
+ from conan.tools.cmake import CMake
129
+ class PkgConan(ConanFile):
130
+ requires = "liba/1.0", "libb/1.0"
131
+ settings = "os", "arch", "compiler", "build_type"
132
+ generators = "CMakeDeps"
133
+ """ )
134
+ c .save ({"conanfile.py" : conanfile }, clean_first = True )
135
+
136
+ # Now with a deployment
137
+ c .run (f"install . -c tools.cmake.cmakedeps:new={ new_value } --deployer=full_deploy" )
138
+ cmake_paths = c .load ("conan_cmakedeps_paths.cmake" )
139
+ assert 'set(libb_DIR "${CMAKE_CURRENT_LIST_DIR}/full_deploy/host/libb/1.0")' in cmake_paths
140
+ assert ('set(CONAN_RUNTIME_LIB_DIRS "$<$<CONFIG:Release>:${CMAKE_CURRENT_LIST_DIR}'
141
+ '/full_deploy/host/liba/1.0/bina>"' ) in cmake_paths
142
+ liba_config = c .load ("liba-config.cmake" )
143
+ assert ('include("${CMAKE_CURRENT_LIST_DIR}/full_deploy/'
144
+ 'host/liba/1.0/share/cmake/crypto.cmake")' ) in liba_config
145
+ liba_targets = c .load ("liba-Targets-release.cmake" )
146
+ assert ('set(liba_PACKAGE_FOLDER_RELEASE "${CMAKE_CURRENT_LIST_DIR}/full_deploy/'
147
+ 'host/liba/1.0")' ) in liba_targets
148
+ assert ('set(liba_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/full_deploy/'
149
+ 'host/liba/1.0/includea" )' ) in liba_targets
150
+
98
151
def test_cmakeconfigdeps_recipe ():
99
152
c = TestClient ()
100
153
conanfile = textwrap .dedent ("""
0 commit comments