[CMake] How to find vcvarsall.bat (e.g. at "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC")? CMAKE_LINKER?
Niels Dekker - address until 2018
niels_dekker_address_until_2018 at xs4all.nl
Fri May 9 05:29:07 EDT 2014
Thanks for suggesting CMAKE_CXX_COMPILER, David. Cool! Indeed, the
following appears to work fine, as I tested with CMake 2.8.12.2 (for
both Visual C++ 2008 and Visual C++ 2013):
get_filename_component(MY_COMPILER_DIR
${CMAKE_CXX_COMPILER} DIRECTORY)
find_file(MY_VCVARSALL_BAT vcvarsall.bat
"${MY_COMPILER_DIR}/.." "${MY_COMPILER_DIR}/../..")
Does CMAKE_CXX_COMPILER always provide the full path name of the
compiler, when we use the current version of CMake (2.8.12.2)? In the
past it did not, apparently, as a CMakeCache.txt file generated by CMake
2.8.8 simply had "cl" as compiler file path:
//C++ compiler
CMAKE_CXX_COMPILER:FILEPATH=cl
I cannot find the CMAKE_CXX_COMPILER variable in the CMakeCache.txt
files I generated by CMake 2.8.12.2. Is there an option to get such
CMake variables into CMakeCache.txt?
Kind regards, Niels
On 2014-05-09 03:32, David Cole wrote:
> In CMakeCache.txt, for a Visual Studio based build where C and/or C++
> has been enabled:
>
> //CXX compiler
> CMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual
> Studio 11.0/VC/bin/cl.exe
>
> //C compiler
> CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio
> 11.0/VC/bin/cl.exe
>
> Those are as rock solid a basis as you'll get for a "typical" visual
> studio build. I think it would be wiser to depend on those than on the
> CMAKE_LINKER variable.
>
> Microsoft has a habit of assuming things like this are internal
> implementation details, though, and they often move things around from
> version to version.
>
> So nothing is guaranteed.
>
> But I would think the compiler variables would be better suited if you
> don't want to rely on ENV or registry... I would point out however, that
> you don't need to rely on any cmake vars or any cmake commands having
> been run if you go with ENV or registry.
More information about the CMake
mailing list