Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set PATH environment variable in CMake script?

Tags:

cmake

I want to build my sources by Mingw compiler which in not placed on my system PATH. I tried this in the beginning of my script:

set(Env{PATH} "c:/MyProject/Tools/mingw/bin/" "c:/MyProject/Tools/mingw/msys/1.0/bin/")

And this:

set(CMAKE_PROGRAM_PATH "c:/MyProject/Tools/mingw/bin/"   "c:/MyProject/Tools/mingw/msys/1.0/bin/")
set(CMAKE_LIBRARY_PATH "c:/MyProject/Tools/mingw/bin/" "c:/MyProject/Tools/mingw/msys/1.0/bin/")
set(CMAKE_SYSTEM_PROGRAM_PATH "c:/MyProject/Tools/mingw/bin/" "c:/MyProject/Tools/mingw/msys/1.0/bin/")
set(CMAKE_SYSTEM_PREFIX_PATH "c:/MyProject/Tools/mingw/bin/" "c:/MyProject/Tools/mingw/msys/1.0/bin/")

The first variant doesn't work at all. A suggest that I can't overwrite the value of the environment variable in CMake script. The second script finds my mingw compiler, but catches the error while running gcc (can't find libgmp-10.dll which needs by gcc). This is because the PATH variable is not set to my Mingw.

like image 220
Aleksei Avatar asked Sep 28 '11 14:09

Aleksei


1 Answers

CMAKE_SYSTEM_PROGRAM_PATH is not meant to be modified, use

LIST(APPEND CMAKE_PROGRAM_PATH  "c:/MyProject/Tools/mingw/bin/" ...)
like image 131
Ding-Yi Chen Avatar answered Oct 12 '22 07:10

Ding-Yi Chen