Skip to content

Commit 1fb04e9

Browse files
authored
Fix potential None and PackageType comparison when deducing cpp_info (#19494)
* Fix None comparison with potential PackageType in components * Invert order * simplify * rename test * Fix
1 parent aef21b5 commit 1fb04e9

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

conan/internal/model/cpp_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def deduce_locations(self, conanfile, component_name=""):
659659
return
660660

661661
# automatic location deduction from a single .lib=["lib"]
662-
if self._type not in [None, PackageType.SHARED, PackageType.STATIC]:
662+
if self._type is not None and self._type not in [PackageType.SHARED, PackageType.STATIC]:
663663
raise ConanException(f"{name} has a library but .type {self._type} is not static/shared")
664664

665665
# If no location is defined, it's time to guess the location

test/integration/toolchains/cmake/cmakedeps2/test_cmakedeps.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,17 @@ def package_info(self):
391391
" $<$<CONFIG:RELEASE>:MyOpenMPILib>)" in dep
392392

393393

394+
def test_cmake_component_type_none_check():
395+
tc = TestClient()
396+
dep = (GenConanfile("dep", "0.1")
397+
.with_package_file("lib/libmain.so", "dynamic library")
398+
.with_package_info({"components": {"main": {"libs": ["libmain.so"], "type": "'shared-library'"}}}))
399+
tc.save({"conanfile.py": dep})
400+
tc.run("create")
401+
tc.run("install --requires=dep/0.1 -g CMakeConfigDeps")
402+
assert "None is not a valid PackageType" not in tc.out
403+
404+
394405
def test_cmake_extra_dependencies_components():
395406
tc = TestClient()
396407
dep = textwrap.dedent("""

0 commit comments

Comments
 (0)