0

I'm using CMake 3.23 with Visual Studio 2022. From everything I found about cmake --build command it should be running msbuild, but evidently it's running devenv instead. Is there some setting I'm not aware of? How do I get it to run msbuild so I can pass options to it?

This is my generator command:

cmake -G "Visual Studio 17" -A x64 -T v143 ..

And then cmake --build is running devenv instead of msbuild:

cmake --build . --config Release -- /verbosity:detailed

Microsoft Visual Studio 2022 Version 17.2.3.
Copyright (C) Microsoft Corp. All rights reserved.

Invalid Command Line. Unknown Switch : verbosity:detailed.

Use:
devenv  [solutionfile | projectfile | folder | anyfile.ext]  [switches]
Igor
  • 15
  • 4
  • In case it is not just a typo the generator string has to be `"Visual Studio 17 2022"`. CMake uses MSBuild as default build tool for the Visual Studio generators. Did you cleaned the the build dir before the configuration step? I always prefer to give source and build directory explicitly to the CMake configuration command `cmake -S -B -G "..." -A x64` and `cmake --build --target ALL_BUILD --config Release -- ...` for the CMake build command. Try to omit the toolset definition `-T v143` from the command line. – vre Jul 20 '22 at 20:56
  • Thank you for the response. I tried all of your recommendations and I'm still getting devenv. There must be some kind of setting that determines whether to run msbuild or devenv. – Igor Jul 20 '22 at 22:27
  • Do you have a CMakePresets.json file in the root folder of the project and use the CMake that comes bundled with Visual Studio? There are a few reports when googling for your issue. Try to use a separate CMake installation by downloading it from cmake.org – vre Jul 21 '22 at 05:27
  • Another thing comes to mind. Try to run your CMake commands from a Visual Studio command line prompt. – vre Jul 21 '22 at 05:36

1 Answers1

1

CMake by default is using MSBuild and falls back to devenv if you either requested it deliberately (with CMAKE_MAKE_PROGRAM) or you have an Intel Fortran project in which case it has to use devenv.

You can check if it found MSBuild by checking the CMAKE_VS_MSBUILD_COMMAND variable. And you can force CMake to use MSBuild by setting CMAKE_MAKE_PROGRAM to the MSBuild path (although I don't know how it will behave if you have a Fortran project).

ixSci
  • 13,100
  • 5
  • 45
  • 79