On May 10 2014, Iulian-Nicu Şerbănoiu wrote:
Isn't it better to use vsvars32.bat? (or vsvars64.bat? - don't have
a 64 bit windows)

vcvarsall.bat supports both 32-bits and 64-bits, as it may calls either vcvars32.bat or vcvars64.bat (depending on its optional argument, see http://msdn.microsoft.com/en-us/library/x4d2c09s.aspx). But indeed, if you only have 32-bits Windows, you might as well call vcvars32.bat directly.

Here is the batch script for VS 2013, 2012, 2010 (priority in this
specific order)
~~~~~~~~~
IF  EXIST  "%VS120COMNTOOLS%"  CALL  "%VS120COMNTOOLS%vsvars32.bat"  &&SET  
GENERATOR="Visual Studio 12"  &&GOTO  BUILD
IF  EXIST  "%VS110COMNTOOLS%"  CALL  "%VS110COMNTOOLS%vsvars32.bat"  &&SET  
GENERATOR="Visual Studio 11"  &&GOTO  BUILD
IF  EXIST  "%VS100COMNTOOLS%"  CALL  "%VS100COMNTOOLS%vsvars32.bat"  &&SET  
GENERATOR="Visual Studio 10"  &&GOTO  BUILD

Thank, Iulian. But my original question was about finding vcvarsall.bat from within CMakeLists.txt, and whether it is okay to use CMAKE_LINKER, given the fact that CMAKE_LINKER is undocumented. David Cole suggested me to use CMAKE_CXX_COMPILER instead, which appears to work fine:

  get_filename_component(MY_COMPILER_DIR
    ${CMAKE_CXX_COMPILER} DIRECTORY)
  find_file(MY_VCVARSALL_BAT vcvarsall.bat
    "${MY_COMPILER_DIR}/.." "${MY_COMPILER_DIR}/../..")

Result: MY_VCVARSALL_BAT = C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/vcvarsall.bat :-)

Kind regards, Niels


--

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

Reply via email to