cmake tutorials problems

Hi All!

I have been having problems with going through cmake tutorials as I always get failures when invoking

Cmake build

Or

Cmake –system-information

– Building for: Visual Studio 17 2022

CMake Error at CMakeLists.txt:6 (project):

No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:6 (project):

No CMAKE_CXX_COMPILER could be found.

Error: --system-information failed on internal CMake!

I am invoking the commands through a bash shell within Visual Code running on Windows 11. I have tried setting the ENV variables shown and CC , CXX.

To add to the consternation is if I run CMake Tools extension by using Quick Start everything works with the compiler referenced in the CMakeCache.txt in build.

This is kind of hard to debug since both methods are opaque to me at this point. It would be nice if you could set a cmake debug flag and it would just print.

I suspect there is something between the bash environment and the set of actions used by CMake: Quick tools in Visual Code.

I would like to continue with the tutorials but they all fail in a similar way. Getting in the way of Vulkan programming.

Thanks,

Frank

Which CMake version do you use?

Try to install current Version from cmake.org or:

pip install cmake
cmake --version

You may also try the WindowsToolchain examples.
use example/CMakePresets.json with

cmake --preset <name>
cmake --build --preset <name>

Hi Claus,

I actually tried that and fixed the paths within Visual Studio x64 environment. Didn’t help.

There is just something in the Cmake Tools vs cmake cli. I think that cmake cli is looking to qualify a compiler and it is failing. I am trying to use the x64 cl compiler installed with Visual Studio Community.

I am also trying to figure out how to debug/watch the cmake cli process but I have not yet figured out a logging mechanism
Thanks,
Frank

Hi,

I am trying to use --preset but am unsure how to use it. I found a json file at
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMakeSettingsTemplates\CMakePresets.Windows.json

and the contents seem to indicate what I want. I have made some progress however it counter-intutive that I need this file in the project root directory.

CMake Tools in Visual Code sets it up correctly by referring to kits and setting to amd64 in my case. Works but not helpful when trying to work through a command line tutorial
Thanks,
Frank

Which tutorial do you mean?

cmake.org tutorial or vscode-cmake-tools tutorial?

bash-5.2$ git describe --tags
v0.8.0-12-g17c6d4f
bash-5.2$ git remote -v
claus	git@github.com:ClausKlein/WindowsToolchain.git (fetch)
claus	git@github.com:ClausKlein/WindowsToolchain.git (push)
origin	https://github.com/MarkSchofield/WindowsToolchain.git (fetch)
origin	https://github.com/MarkSchofield/WindowsToolchain.git (push)
bash-5.2$ cd example/
bash-5.2$ cmake --preset .
CMake Error: No such preset in /Users/clausklein/Workspace/cmake/WindowsToolchain/example: "."
Available configure presets:

  "windows-msvc-x64"      - Configure for 'windows-msvc-x64'
  "windows-msvc-amd64"    - Configure for 'windows-msvc-amd64'
  "windows-msvc-x86"      - Configure for 'windows-msvc-x86'
  "windows-msvc-arm64"    - Configure for 'windows-msvc-arm64'
  "windows-clang-x64"     - Configure for 'windows-clang-x64'
  "windows-clang-amd64"   - Configure for 'windows-clang-amd64'
  "windows-clangcl-x64"   - Configure for 'windows-clangcl-x64'
  "windows-clangcl-amd64" - Configure for 'windows-clangcl-amd64'
  "ewdk"                  - EWDK configuration
bash-5.2$ 

why not simple use cmake-gui?

cmake.org tutorial and a few others.

Visual Code and its plugins are out of my scope.

Why not simply work with cmake-gui or cmake on bash?

Well for education purposes of learning how it works.

30+ years ago I was a build engineer and got flown around alot(including months in Paris). After that point in my life I got dragged into more and more marketing and sales events where my brain died. :roll_eyes: . There have been a lot of improvements in the mean time.
Probably should take your advice as my goal really is learning the Vulkan graphics platform. Since most of the tutorials in c++. I want to take what I learn and put it to create libraries for the Rust platform. All means to and end.

I’m working now on a different problem where the linker is not picking up system32 libraries in the x64-debug preset.
More later

Good idea!
Install WSL2 and ubuntu 22.04, it’s so esay on Linux ;-))

LOL you are probably right about OS. My experience with Linux is about 6 years setting up marketing servers and fortifying them. And Raspberry Pi.

I got everything going well now. I ran the exercises in a X64 Dev prompt on windows and they worked. Then I got rid of a hacked path in a .bashrc that gets invoked in the shell env with VScode.

Learn though mistakes. Now onward.
Thanks for your help

Thanks for the git. I will explore it.
You are a mensch !
Frank

Hi Frank,
Have you tried running cmake from cmd.exe or PowerShell instead of a bash shell? Depending on where the bash shell comes from (e.g., Cygwin), it might have its own cmake which doesn’t know where to find the Visual Studio compiler.

I don’t remember having to do anything special to get cmake to find the compiler, although it did have a tendency to prefer mingw over Visual Studio.

Hans