Setting Visual C++ Executable Directories (PATH env variable) for a project in CMake

build, cmake, path, visual-c++

Solution

Now 4 years later with CMake 3.12 you can finally do this by overriding variables:

`CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES`

As a matter of fact, you can modify all of those entries you see in the VC++ Directories tab: `CMAKE_VS_SDK_EXCLUDE_DIRECTORIES` `CMAKE_VS_SDK_INCLUDE_DIRECTORIES` `CMAKE_VS_SDK_LIBRARY_DIRECTORIES` `CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES` `CMAKE_VS_SDK_REFERENCE_DIRECTORIES` `CMAKE_VS_SDK_SOURCE_DIRECTORIES`

However, be careful: this a write-only variable. The best thing you can do right now not to lose the directories that are there by default is this: `set( CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES $(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(FxCopDir);$(PATH);WhateverElseYouNeed )`

Problem

On the project property pages there is a VC++ Directories tab, on that tab there is an "Executable Directories" option which is basically there to set the PATH variable when building the project. I need to add the path to a Python interpreter there, which I know about and can infer beforehand by means of the ${CMAKE_SOURCE_DIR} variable. Is there currently way to set it in CMakeLists.txt? Thanks.

Original source