How to set PATH environment variable in CMake script?

You might approach it as if it were a cross compiling toolchain, even if you're not cross compiling from Linux to Windows as in this example:

http://www.vtk.org/Wiki/CmakeMingw

After you follow that guide you set the mingw toolchain at the command line when calling cmake:

~/src/helloworld/ $ mkdir build
~/src/helloworld/ $ cd build
~/src/helloworld/build/ $ cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake

then if you're using this a whole lot you can make an alias to limit typing in that ugly -D every time you want to regenerate makefiles:

alias mingw-cmake='cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake'

CMAKE_SYSTEM_PROGRAM_PATH is not meant to be modified, use

LIST(APPEND CMAKE_PROGRAM_PATH  "c:/MyProject/Tools/mingw/bin/" ...)

Tags:

Cmake