[CMake] MSVC Version Location for VisualStudio Install

J. Caleb Wherry calebwherry at gmail.com
Tue Nov 12 17:52:18 EST 2019


All,

I have been adding support for VS2019 to our build and ran into some CMake
code that was hard coded for a specific version related to MSVC.
Specifically, it is the folder under the VS install dir with version like
"14.23.28105". It is in the path for where the compiler is found but I
can't find an actual variable that contains this version, is there one? I
need access to this folder because we ship the vc_redist and MergeModules
and need to install those. Since they are different between VS2017 and
VS2019 (and we have support for building in multiple VS versions at a
time), I need a way to get this version. I know I can parse it but was
hoping it was exposed some other way... FWIW: I already get the path to VS
version to use as a generator with vswhere so I am open to using that as
well if need be.

Here is the output of CMake with the version bolded for what I am referring
to.

---
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.
-- The C compiler identification is MSVC 19.23.28106.4
-- The CXX compiler identification is MSVC 19.23.28106.4
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Professional/VC/Tools/MSVC/*14.23.28105*/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Professional/VC/Tools/MSVC/*14.23.28105*/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Professional/VC/Tools/MSVC/*14.23.28105*/bin/Hostx64/x64/cl.exe
-- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Professional/VC/Tools/MSVC/*14.23.28105*/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Professional/VC/Tools/MSVC/*14.23.28105*/bin/Hostx64/x64/cl.exe
-- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done

<snip>

---

Thanks,
Caleb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191112/ae727da1/attachment.html>


More information about the CMake mailing list