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.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake