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 cmake target not generated with CMake2 generator when only system… #17868

Merged
Merged
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
2 changes: 1 addition & 1 deletion conan/tools/cmake/cmakedeps2/target_configuration.py
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ def _get_libs(self, cpp_info, pkg_name, pkg_folder, pkg_folder_var) -> dict:
return libs

def _get_cmake_lib(self, info, components, pkg_folder, pkg_folder_var):
if info.exe or not (info.includedirs or info.libs):
if info.exe or not (info.includedirs or info.libs or info.system_libs):
return

includedirs = ";".join(self._path(i, pkg_folder, pkg_folder_var)
26 changes: 26 additions & 0 deletions test/integration/toolchains/cmake/cmakedeps2/test_cmakedeps.py
Original file line number Diff line number Diff line change
@@ -152,3 +152,29 @@ class TestConan(ConanFile):
assert "WARN: Using the new CMakeConfigDeps generator" in c.out
c.run("install app -c tools.cmake.cmakedeps:new=recipe_will_break")
assert "WARN: Using the new CMakeConfigDeps generator" in c.out


def test_system_wrappers():
c = TestClient()
conanfile = textwrap.dedent("""
import os
from conan.tools.files import copy
from conan import ConanFile
class TestConan(ConanFile):
name = "lib"
version = "system"
package_type = "shared-library"

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.system_libs = ["my_system_cool_lib"]
""")
c.save({"conanfile.py": conanfile})
c.run("create .")

c.run(f"install --requires=lib/system -g CMakeConfigDeps "
f"-c tools.cmake.cmakedeps:new={new_value}")
cmake = c.load("lib-Targets-release.cmake")
assert "add_library(lib::lib INTERFACE IMPORTED)" in cmake
assert "target_link_libraries(lib::lib INTERFACE my_system_cool_lib)" in cmake