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

fix new CMakeDeps in-package casing #17330

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions conan/tools/cmake/cmakedeps2/cmakedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ def generate(self):
build_dir = dep.package_folder
pkg_folder = build_dir.replace("\\", "/") if build_dir else None
if pkg_folder:
config_file = ConfigTemplate2(self._cmakedeps, dep).filename
if os.path.isfile(os.path.join(pkg_folder, config_file)):
pkg_paths[pkg_name] = pkg_folder
f = self._cmakedeps.get_cmake_filename(dep)
for filename in (f"{f}-config.cmake", f"{f}Config.cmake"):
if os.path.isfile(os.path.join(pkg_folder, filename)):
pkg_paths[pkg_name] = pkg_folder
continue

# If CMakeDeps generated, the folder is this one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def test_cmake_generated(client):


@pytest.mark.tool("cmake")
def test_cmake_in_package(client):
@pytest.mark.parametrize("lowercase", [False, True])
def test_cmake_in_package(client, lowercase):
c = client
# same, but in-package
dep = textwrap.dedent("""
f = "dep-config" if lowercase else "depConfig"
dep = textwrap.dedent(f"""
import os
from conan import ConanFile
from conan.tools.files import save
Expand All @@ -60,7 +62,7 @@ class Pkg(ConanFile):

def package(self):
content = 'message(STATUS "Hello from dep dep-Config.cmake!!!!!")'
save(self, os.path.join(self.package_folder, "cmake", "dep-config.cmake"), content)
save(self, os.path.join(self.package_folder, "cmake", "{f}.cmake"), content)
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs = ["cmake"]
Expand Down