Thanks for your suggestions, J Decker and David. I find both approaches (using registry entry paths as hints to find_program or using $ENV{VS110COMNTOOLS}) quite interesting. However, I'd rather not have to write such code for each compiler version separately, in my CMakeLists. Also I have the impression that CMake already "knows" the directory path name of the selected compiler (current generator), so it would be helpful if CMake could tell me so directly.

We currently find vcvarsall.bat as follows:

  get_filename_component(MY_LINKER_DIR ${CMAKE_LINKER} DIRECTORY)
  find_file(MY_VCVARSALL_BAT vcvarsall.bat
    "${MY_LINKER_DIR}/.." "${MY_LINKER_DIR}/../..")

This appears to work fine for any Visual C++ version I have tested so far, including both 32 and 64 bits. However, it assumes that CMake generates this CMAKE_LINKER variable. Is it okay to make that assumption?

Kind regards, Niels

On 5/8/2014 11:09 PM, David Cole wrote:
How about:

    if(EXISTS "$ENV{VS110COMNTOOLS}../../VC")
       get_filename_component(VC11_DIR "$ENV{VS110COMNTOOLS}../../VC"
ABSOLUTE)
    endif()
    if(EXISTS "$ENV{VS120COMNTOOLS}../../VC")
       get_filename_component(VC12_DIR "$ENV{VS120COMNTOOLS}../../VC"
ABSOLUTE)
    endif()
    message(STATUS "VC11_DIR='${VC11_DIR}'")
    message(STATUS "VC12_DIR='${VC12_DIR}'")

--

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