diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index b8749e55a8500..acd07028eaecc 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -1,6 +1,7 @@ import os import fnmatch import textwrap +from contextlib import contextmanager from functools import total_ordering from conans.errors import ConanInvalidConfiguration from conans import ConanFile, AutoToolsBuildEnvironment, tools @@ -680,6 +681,20 @@ def _cc(self): return "gcc" return "cc" + @contextmanager + def _make_context(self): + if self._use_nmake: + # Windows: when cmake generates its cache, it populates some environment variables as well. + # If cmake also initiates openssl build, their values (containing spaces and forward slashes) + # break nmake (don't know about mingw make). So we fix them + def sanitize_env_var(var): + return '"{}"'.format(var).replace('/', '\\') if '"' not in var else var + env = {key: sanitize_env_var(tools.get_env(key)) for key in ("CC", "RC") if tools.get_env(key)} + with tools.environment_append(env): + yield + else: + yield + def build(self): with tools.vcvars(self.settings) if self._use_nmake else tools.no_op(): env_vars = {"PERL": self._perl} @@ -699,7 +714,8 @@ def build(self): else: self._patch_configure() self._patch_makefile_org() - self._make() + with self._make_context(): + self._make() @property def _cross_building(self):