Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"external_package" property for CMakeDeps #9087

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions conan/tools/cmake/cmakedeps/cmakedeps.py
Expand Up @@ -60,6 +60,10 @@ def content(self):
if dep.is_build_context and dep.ref.name not in self.build_context_activated:
continue

if dep.new_cpp_info.get_property("external_package", "CMakeDeps"):
# Skip the generation of config files for this node, it will be located externally
continue

config_version = ConfigVersionTemplate(self, require, dep)
ret[config_version.filename] = config_version.render()

Expand Down
Empty file.
Empty file.
@@ -0,0 +1,39 @@
import os

from conans.test.assets.genconanfile import GenConanfile
from conans.test.utils.tools import TestClient


def test_package_from_system():
"""
If a node declares "system_package" property, the CMakeDeps generator will skip generating
the -config.cmake and the other files for that node but will keep the "find_dependency" for
the nodes depending on it. That will cause that cmake looks for the config files elsewhere
https://github.com/conan-io/conan/issues/8919"""
client = TestClient()
dep2 = str(GenConanfile().with_name("dep2").with_version("1.0")
.with_settings("os", "arch", "build_type", "compiler"))
dep2 += """
def package_info(self):
self.cpp_info.set_property("external_package", True)
lasote marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.set_property("cmake_file_name", "custom_dep2")

"""
client.save({"conanfile.py": dep2})
client.run("create .")

dep1 = GenConanfile().with_name("dep1").with_version("1.0").with_require("dep2/1.0")\
.with_settings("os", "arch", "build_type", "compiler")
client.save({"conanfile.py": dep1})
client.run("create .")

consumer = GenConanfile().with_name("consumer").with_version("1.0").\
with_require("dep1/1.0").with_generator("CMakeDeps").\
with_settings("os", "arch", "build_type", "compiler")
client.save({"conanfile.py": consumer})
client.run("install .")
assert os.path.exists(os.path.join(client.current_folder, "dep1-config.cmake"))
assert not os.path.exists(os.path.join(client.current_folder, "dep2-config.cmake"))
assert not os.path.exists(os.path.join(client.current_folder, "custom_dep2-config.cmake"))
contents = client.load("dep1-release-x86_64-data.cmake")
assert 'set(dep1_FIND_DEPENDENCY_NAMES ${dep1_FIND_DEPENDENCY_NAMES} custom_dep2)' in contents
1 change: 0 additions & 1 deletion conans/test/unittests/tools/cmake/test_cmakedeps.py
Expand Up @@ -171,4 +171,3 @@ def test_component_name_same_package():
data_cmake = files["mypkg-release-x86-data.cmake"]
assert 'set(mypkg_mypkg_INCLUDE_DIRS_RELEASE ' \
'"${mypkg_PACKAGE_FOLDER_RELEASE}/includedirs1")' in data_cmake