Skip to content

Commit

Permalink
Fix unsafe check of the compiler in the CMakeToolchain generator (#9801)
Browse files Browse the repository at this point in the history
The compiler variable here must not be a NoneType object to use `in`.
This will result in an error when attempting to package a header-only library.
This commit fixes this check.
It first verifies the compiler is not None before checking it.
  • Loading branch information
jwillikers authored Oct 14, 2021
1 parent d81f5a1 commit 9e50814
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion conan/tools/cmake/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def context(self):
compiler = self._conanfile.settings.get_safe("compiler")
# TODO: Check if really necessary now that conanvcvars is used
if (generator is not None and "Ninja" in generator
and ("Visual" in compiler or compiler == "msvc")):
and (compiler is not None and "Visual" in compiler or compiler == "msvc")):
compiler = "cl"
else:
compiler = None # compiler defined by default
Expand Down

0 comments on commit 9e50814

Please sign in to comment.