[bug] toolchain file: CMAKE_GENERATOR_PLATFORM regression in 1.36.0?
See original GitHub issueEnvironment Details (include every applicable attribute)
- Operating System+version: Windows 10
- Compiler+version: Visual Studio 2019 + Ninja generator
- Conan version: 1.36.0
- Python version: 3.9.1
Steps to reproduce (Include if Applicable)
-
add a basic toolchain file in
conanfile.py:from conans import ConanFile, tools from conan.tools.cmake import CMakeToolchain class TestConan(ConanFile): ... def generate(self): tc = CMakeToolchain(self) tc.generate() ... -
install some external libraries with this conanfile:
mkdir build cd build conan install .. -g cmake_find_package -g cmake_find_package_multi -
call CMake on a basic top CMakeLists with this toochain file and Ninja generator:
cmake .. -DCMAKE_TOOLCHAIN_FILE=<path to toolchaine file> -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja
Logs (Executed commands with output) (Include/Attach if Applicable)
[cmake] Not searching for unused variables given on the command line.
[cmake] Using Conan toolchain through d:/projects/test/build/msvc2019_x64_x64_Release/conan_generators/conan_toolchain.cmake.
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake] Generator
[cmake]
[cmake] Ninja
[cmake]
[cmake] does not support platform specification, but platform
[cmake]
[cmake] x64
[cmake]
[cmake] was specified.
[cmake]
[cmake]
[cmake] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
[cmake] CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
[cmake] -- Configuring incomplete, errors occurred!
This issue was fixed in 1.33.0 I think: https://github.com/conan-io/conan/issues/7485. At least It was working in conan 1.35
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[feature] [toolchain.cmake] Set platform and toolset only if ...
Use case: Using MSVC with Ninja as CMake Generator. It doesn't support PLATFORM and TOOLSET variables and errors out on them.
Read more >cmake-toolchains(7) — CMake 3.25.1 Documentation
Introduction¶. CMake uses a toolchain of utilities to compile, link libraries and create archives, and other tasks to drive the build.
Read more >Changelog — conan 1.36.0 documentation
It can be used as a CMake toolchain to perform a transparent CMake usage, without include any line of cmake code related to...
Read more >CMake 3.21.0-rc2 is ready for testing - Kitware Inc.
The “Visual Studio 17 2022” generator was added. This is ... “cmake(1)” gained the “–toolchain <path/to/file>” command-line
Read more >man page cmake-modules section 7
The module will accept files and libraries as well as separate ... <platform> Pass a generator-specific platform name to the CMake command ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, I agree! This is the UX part that is missing at the moment. The key idea is that the generator needs to be know at install time, so it might be something like this:
We still need to implement this, so at the moment the only way to define it is via the constructor of CMakeToolchain. We will try hard to provide this in next 1.37. The main problem is that there are few things that depend on the generator in the toolchain and generate() step:
So we needed to start introducing some changes, like the
conanbuild.jsonfile, which is kind of a CMake presets (but for 3.15), that contains some information like the CMake generator or the CMake toolchain file name, and generating theconanvcvars.batfile fromCMakeToolchain.generate().https://github.com/conan-io/conan/pull/8899/files added Conan configuration for CMakeToolchain selection of CMake generator, which seems to be resolving this issue. This will be in 1.37.