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

[bug] Using CMakeToolchain + msvc impossible with standard installation of VS2015 #9888

Closed
eleftg opened this issue Oct 27, 2021 · 4 comments · Fixed by #9889
Closed

[bug] Using CMakeToolchain + msvc impossible with standard installation of VS2015 #9888

eleftg opened this issue Oct 27, 2021 · 4 comments · Fixed by #9889
Assignees
Milestone

Comments

@eleftg
Copy link

eleftg commented Oct 27, 2021

Environment Details

  • Operating System+version: Windows ANY
  • Compiler+version: cl.exe 19.00 (msvc 19.0 according to settings.yml) from a standard VS2015 installation
  • Conan version: 1.41.0
  • Python version: 3.8.9

Steps to reproduce

When using the msvc 19.0 compiler of a "standard" Visual Studio 2015 installation ("standard" meaning that it's not the "MSVC v140 - VS 2015 C++ Build Tools (v14.00)" included in later editions VS2017 & VS2019), the CMakeToolchain crashes while calling the generated conanvcvars.bat. By examining the latter (see below), it turns out the argument -vcvars_ver is passed to the vcvarsall.bat activation script. However, that particular version of the script doesn't expect such an argument - since it was added from VS2017 onwards for activating older toolsets in newer versions of Visual Studio - so it errors out.

@echo off
set "VSCMD_START_DIR=%CD%" && call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat"  amd64 -vcvars_ver=14.0

whereas the correct call should be:

@echo off
set "VSCMD_START_DIR=%CD%" && call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat"  amd64

Logs

Configuration (profile_host):
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=19.0
os=Windows
[options]
*:shared=True
[build_requires]
[env]
CC=cl
CXX=cl
Configuration (profile_build):
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=19.0
os=Windows
[options]
[build_requires]
[env]
CC=cl
CXX=cl
zlib/1.2.11@compression/stable: Forced build from source
zlib/1.2.11@compression/stable (test package): Installing package
Requirements
    zlib/1.2.11@compression/stable from local cache - Cache
Packages
    zlib/1.2.11@compression/stable:75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3 - Build

Installing (downloading, building) binaries...
zlib/1.2.11@compression/stable: Configuring sources in C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\source

zlib/1.2.11@compression/stable: Copying sources to build folder
zlib/1.2.11@compression/stable: Building your package in C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\build\75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3
zlib/1.2.11@compression/stable: Generator txt created conanbuildinfo.txt
zlib/1.2.11@compression/stable: Calling generate()
zlib/1.2.11@compression/stable: Aggregating env generators
zlib/1.2.11@compression/stable: Calling build()
zlib/1.2.11@compression/stable: CMake command: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/build/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/package/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3" "C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\build\75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3\_source_subfolder"

----Running------
> "C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\build\75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3\conanbuild.bat" && cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/build/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/package/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3" "C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\build\75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3\_source_subfolder"
-----------------
Logging command output to file 'C:\gitlab-runner\builds\9fb8a5b5\0\io\zlib\.conan\data\zlib\1.2.11\compression\stable\build\75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3\_build_subfolder\conan_run.log'
Error in script usage. The correct usage is:

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" [option]

  or

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" [option] store

  or

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" [option] [version number]

  or

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" [option] store [version number]

where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm

where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK

:

The store parameter sets environment variables to support

  store (rather than desktop) development.

:

For example:

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x86_amd64

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x86_arm store

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x86_amd64 10.0.10240.0

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x86_arm store 10.0.10240.0

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x64 8.1

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC/vcvarsall.bat" x64 store 8.1

:

Please make sure either Visual Studio or C++ Build SKU is installed.

Using Conan toolchain through C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/build/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3/conan_toolchain.cmake.
-- Conan toolchain: Setting BUILD_SHARED_LIBS= ON
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/build/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3/_build_subfolder/CMakeFiles/CMakeOutput.log".
See also "C:/gitlab-runner/builds/9fb8a5b5/0/io/zlib/.conan/data/zlib/1.2.11/compression/stable/build/75d5ce8d183d5e36dab24b5c22b2e9d17f3981e3/_build_subfolder/CMakeFiles/CMakeError.log".

On a different build node equipped with VS2019 Build Tools + MSVC v140 toolset and using the same profile with the sole addition of tools.microsoft.msbuild:vs_version=16, it worked just fine.

However, I would expect conan to do the right thing (stopping short of specifying -vcvars_ver) also when activating a "traditional" VS2015 installation.

@memsharded
Copy link
Member

Hi @eleftg

You are correct. #9889 should fix it (in case you want to run from that source branch to validate), and it will be released in 1.42 very soon.

@memsharded memsharded added this to the 1.42 milestone Oct 27, 2021
@eleftg
Copy link
Author

eleftg commented Oct 28, 2021

Hi @eleftg

You are correct. #9889 should fix it (in case you want to run from that source branch to validate), and it will be released in 1.42 very soon.

Thanks for the lightning-fast response & fix! I'll try testing it as soon as possible and report back.

@eleftg
Copy link
Author

eleftg commented Nov 3, 2021

Tested it with 1.42.0 and it now works perfectly.

@memsharded
Copy link
Member

Tested it with 1.42.0 and it now works perfectly.

Thanks for telling @eleftg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants