Repository: conan-io/conan-center-index

Issue:
[openssl] openssl/1.1.1j Fails to build first time (once) when using cmake-conan with "cannot open input file 'apps\app_rand.obj'"
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **openssl/1.1.1j**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Visual Studio 2017**
  * Conan version: **conan 1.32.1**
  * Python version: **Python 3.7.4**

### Steps to reproduce (Include if Applicable)

Let's say we have `conan-bug` directory, where inside we have:

**profile.txt**:
```
include(default)
[settings]
compiler="Visual Studio"
compiler.version=15
arch=x86
arch_build=x86
```

**conanfile.txt**:
```
[requires]
openssl/1.1.1j@

[options]
openssl:shared=True

[generators]
cmake_find_package
cmake_paths
```

**CMakeLists.txt**:
```
cmake_minimum_required(VERSION 3.16)

project(ConanBug)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake-conan-0.15")
include(conan)

add_executable(${PROJECT_NAME})

conan_cmake_run(
    BUILD missing
    BUILD_TYPE "${CMAKE_BUILD_TYPE}"
    CONANFILE conanfile.txt
    INSTALL_FOLDER "${PROJECT_SOURCE_DIR}/build"
    PROFILE "${PROJECT_SOURCE_DIR}/profile.txt"
    SETTINGS "build_type=${CMAKE_BUILD_TYPE}"
)
include(${PROJECT_SOURCE_DIR}/build/conan_paths.cmake)
```

**cmake-conan-0.15** directory from:
https://github.com/conan-io/cmake-conan/releases/tag/v0.15

Now, in `cmd.exe` run:

```
conan.exe remove openssl --force
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
"C:\Program Files\CMake\bin\cmake.exe" -G Ninja -DCMAKE_BUILD_TYPE=Debug -B build .
```

Output with failure:
https://gist.github.com/Talkless/28fe39d2176e00b25d9987caef9009be (using gist as log conflicts with github formatting somehow).

Intrestingly, if I run same `cmake` command again (second time) - build succeeds (`openssl` is built)!

If I remove `openssl` package with `conan.exe remove openssl --force` and run `cmake` again, it also succeeds!

Now to actually reproduce build, I have to remove `openssl` package *and* `build` directory.

This issue is experienced only with `openssl` package so far.



Discussion:
As an enterprise consumer, I strongly disagree with this comment... https://github.com/openssl/openssl/issues/12563#issuecomment-670800116

Most often this type of problem is the firewall/anti-virus.... You might want to try disabling those... check method 6 https://support.microsoft.com/en-us/topic/-windows-cannot-access-the-specified-device-path-or-file-error-when-you-try-to-install-update-or-start-a-program-or-file-46361133-47ed-6967-c13e-e75d3cc29657 it's a fairly well known problem

_We've_ needed to disable the Windows Indexing Service on our build node, check this https://www.ghacks.net/2017/08/10/manage-windows-10-search-indexing/ how to

Both of these tend to open new/modified files which can prevent other processes from opening them... in this case the openssl build process.


@prince-chrismc 
> Most often this type of problem is the firewall/anti-virus....

No. I have the same issue and can explain what's going on. Somehow openssl (conan?) configuration code detect cl.exe path as
`C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe`. So when `nmake` is called it invokes the following command to create `apps\app_rand.obj`:
```
	C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe  /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"
```
Note `C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe` with spaces without double quotes around. This fails SILENTLY with no app_rand.obj created. I've just verified it manually:
```
(conanbuildenv) C:\Users\ContainerAdministrator\.conan\data\openssl\1.1.1h\_\_\build\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\source_subfolder>nmake CC="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe" apps\app_rand.obj

Microsoft (R) Program Maintenance Utility Version 14.16.27045.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
 /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"
        C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
 /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  /Zs /showIncludes "apps\app_rand.c" 2>&1 > apps\app_rand.d

(conanbuildenv) C:\Users\ContainerAdministrator\.conan\data\openssl\1.1.1h\_\_\build\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\source_subfolder>dir apps\*.obj
 Volume in drive C has no label.
 Volume Serial Number is DC8D-FFC1
 ```
Now the correct fix is needed :)
> I have the same issue and can explain what's going on

I love that!

We recently had a similar problem with boost. https://github.com/conan-io/conan-center-index/pull/5099/files,

If I make a PR would you be willing to test it to help confirm the fix? I don't have any problems locally so it's difficult for me to confirm.



> If I make a PR would you be willing to test it to help confirm the fix? I don't have any problems locally so it's difficult for me to confirm.

Sure. Thanks a lot in advance!

For the original issue "it always works the second time", I'd stand by my first suggestion for OP... We have sadly seen this many times.

***

As for the path escape problem... I think I found the issue 🤔 

❓ Are you specifying the compiler?

the following lines prepare the `CC` and `CXX` variables and pass them to perl/msys to apply in the build scripts.

https://github.com/conan-io/conan-center-index/blob/8feafc2df48150492ba13a4d6d09c0d073f33e80/recipes/openssl/1.x.x/conanfile.py#L551-L552

Using a normal command prompt, I get

```txt
openssl/1.1.1j: Calling build()
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.7.7
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
openssl/1.1.1j: using target: VC-conan-Release-Windows-x86_64-Visual Studio-16 -> VC-WIN64A
openssl/1.1.1j: my %targets = (
    "VC-conan-Release-Windows-x86_64-Visual Studio-16" => {
        inherit_from => [ "VC-WIN64A" ],
        cflags => add("-O2 -Ob2 -MD"),
        cxxflags => add("-O2 -Ob2 -MD"),
        defines => add("NDEBUG"),
        includes => add("C:/.conan/9d4cd9/1/include"),
        lflags => add(""),
    },
);
```

Shortly after it happily compiles

```
Microsoft (R) Program Maintenance Utility Version 14.27.29112.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl  /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD -O2 -Ob2 -MD /W3 /wd4090 /nologo /O2 /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_MONT5" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"KECCAK1600_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"X25519_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\res\"" -D"ENGINESDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" -D"NDEBUG" -I"C:/.conan/9d4cd9/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"
```

↪️ Notice it's using `cl.exe` directly from my path, so no funky path problems,

However with `CC` and `CXX` as follows

```env
cc=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe
cxx=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe
```

OpenSSL build receives

```
openssl/1.1.1j: Calling build()
Conan:vcvars already set
openssl/1.1.1j: using target: VC-conan-Release-Windows-x86_64-Visual Studio-16 -> VC-WIN64A
openssl/1.1.1j: my %targets = (
    "VC-conan-Release-Windows-x86_64-Visual Studio-16" => {
        inherit_from => [ "VC-WIN64A" ],
        cflags => add("-O2 -Ob2 -MD"),
        cxxflags => add("-O2 -Ob2 -MD"),
        defines => add("NDEBUG"),
        includes => add("C:/.conan/9d4cd9/1/include"),
        lflags => add(""),
        cc => "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\cl.exe",
        cxx => "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\cl.exe",
    },
);
```

Than I can reproduce the original issues

```
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe  /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD -O2 -Ob2 -MD /W3 /wd4090 /nologo /O2 /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_MONT5" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"KECCAK1600_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"X25519_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\res\"" -D"ENGINESDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" -D"NDEBUG" -I"C:/.conan/9d4cd9/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"
```

It does not print the `app_rand.c` as it should when it's successful.

Which is later followed by

```
LINK : fatal error LNK1181: cannot open input file 'apps\app_rand.obj'
```

***

As for fixing the problem, I'm at odds.

Adding `"` around the path gives

```
Bareword found where operator expected at (eval 13) line 13, near """C"
        (Missing operator before C?)

Failure!  build file wasn't produced.
Please read INSTALL and associated NOTES files.  You may also have to look over
your available compiler tool chain or change your configuration.

syntax error at (eval 13) line 13, near """C"
Unknown regexp modifier "/M" at (eval 13) line 13, at end of line
Unknown regexp modifier "/r" at (eval 13) line 13, at end of line
Unknown regexp modifier "/f" at (eval 13) line 13, at end of line
Unknown regexp modifier "/t" at (eval 13) line 13, at end of line
Unknown regexp modifier "/C" at (eval 13) line 13, at end of line
Unknown regexp modifier "/t" at (eval 13) line 13, at end of line
Unknown regexp modifier "/y" at (eval 13) line 13, at end of line
Unknown regexp modifier "/T" at (eval 13) line 13, at end of line
Unknown regexp modifier "/1" at (eval 13) line 13, at end of line
(eval 13) has too many errors.
```

And using `\ ` does not help

```
        cc => "C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe",
        cxx => "C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe",
```

I still have the original issue 😑 

To my knowledge thus far it seems to be a problem internal with the OpenSSL `nmake` in `perl` that is causing the problem.

> Are you specifying the compiler?

No. it's a CI job in a Docker container, involving conan.cmake and building missing conan packages from where. Simple `conan install openssl/1.1.1h@ -s arch=x86 --build openssl` in a clean container works as expected. OK, I'm trying to create a minimal test case that triggers the failure. It turns to be not that easy as I thought.
> It turns to be not that easy as I thought.

It'll be that much more rewarding when we fix it =D
I was able to create a minimal (sort of) test case. Here it is:

CMakeLists.txt
```cmake
cmake_minimum_required(VERSION 3.2)

project(build)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_check()
conan_cmake_run(
  BUILD_REQUIRES
    cmake/3.20.1
  REQUIRES
    openssl/1.1.1h
  SETTINGS
    cmake:arch=x86_64
    nasm:arch=x86_64
    strawberryperl:arch=x86_64
  BUILD openssl
)
```
Execute the following commands:
```
mkdir conan
echo [generators] > conan/conanfile.txt
conan install conan -if conan -g virtualbuildenv -s arch=x86
call conan\activate_build.bat
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE="Debug" ..
```
When I run cmake for the first time, it detects C/C++ compilers and writes the settings into CMakeCache.txt:
```
-- The C compiler identification is MSVC 19.16.27045.0
-- The CXX compiler identification is MSVC 19.16.27045.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.2702
3/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.2702
3/bin/Hostx64/x86/cl.exe -- works
```
when conan.cmake in the same process tries to build openssl package, these settings somehow affect its config:
```
openssl/1.1.1h: my %targets = (
    "VC-conan-Debug-Windows-x86-Visual Studio-15" => {
        inherit_from => [ "VC-WIN32" ],
        cflags => add("-Zi -Ob0 -Od -MDd"),
        cxxflags => add("-Zi -Ob0 -Od -MDd"),

        includes => add("C:/.conan/ceed98/1/include"),
        lflags => add(""),



        cc => "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/
cl.exe",
        cxx => "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86
/cl.exe",



    },
);
```
and openssl build fails. If I rerun cmake after that, C/C++ compiler settings are taken from CMakeCache.txt and do NOT affect openssl config while building:
```
openssl/1.1.1h: my %targets = (
    "VC-conan-Debug-Windows-x86-Visual Studio-15" => {
        inherit_from => [ "VC-WIN32" ],
        cflags => add("-Zi -Ob0 -Od -MDd"),
        cxxflags => add("-Zi -Ob0 -Od -MDd"),

        includes => add("C:/.conan/ceed98/1/include"),
        lflags => add(""),








    },
);
```
Why so? cmake sets some environment variables that affect perl? I have no idea...
BTW, x86_64 build fails just the same way so the test case can be reduced to
```cmake
cmake_minimum_required(VERSION 3.2)

project(build)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_run(
  BUILD_REQUIRES cmake/3.20.1
  REQUIRES openssl/1.1.1h
  BUILD openssl
)
```
and
```bat
mkdir conan
echo [generators] > conan/conanfile.txt
conan install conan -if conan -g virtualbuildenv
call conan\activate_build.bat
mkdir build
cd build
cmake -G Ninja ..
```
> cmake sets some environment variables?

Yes. When cmake initially determines C/C++ compilers, it sets CC/CXX environment variables to the full cl.exe path (forward slashes, no double quotes around) that affect openssl configuration.
@prince-chrismc 
The following seems to be is enough to resolve the issue:
```diff
--- a/recipes/openssl/1.x.x/conanfile.py
+++ b/recipes/openssl/1.x.x/conanfile.py
@@ -635,6 +635,10 @@ class OpenSSLConan(ConanFile):
             if self._use_nmake and self._full_version >= "1.1.0":
                 self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))

+            if tools.os_info.is_windows and not self._win_bash:
+                for v in ['CC', 'CXX', 'RC']:
+                    if v in os.environ and not '"' in os.environ[v]:
+                        os.environ[v] = '"' + os.environ[v].replace('/', '\\') + '"'
             self.run('{perl} ./Configure {args}'.format(perl=self._perl, args=args), win_bash=self._win_bash)

             self._patch_install_name()
```
If it's OK for you I can submit a PR.
Please! This way I can approve it right away =D

Resolving patch:
diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py
--- 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):


Test patch: