I want to build my sources by Mingw compiler wich in not placed on my system PATH. I tried this in the beginning of my script:
我想通过Mingw编译器构建我的源代码,而不是放在我的系统路径上。我在我的剧本的开头尝试过:
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 setted to my Mingw.
第一个变体根本不起作用。建议我不能在CMake脚本中覆盖环境变量的值。第二个脚本找到我的mingw编译器,但是在运行gcc时捕获错误(找不到libgmp-10)。需要的dll)。这是因为路径变量没有被设置为Mingw。
3 个解决方案
#1
1
Write a script file to start CMake.
编写一个脚本文件以启动CMake。
On Windows make a batch file:
在Windows上做一个批处理文件:
@echo off
set path=c:\MyProject\Tools\mingw\bin;c:\MyProject\Tools\mingw\msys\1.0\bin
"C:\Program Files\CMake 2.8\bin\cmake-gui.exe"
On Linux make a bash script:
在Linux上做一个bash脚本:
export PATH=$PATH:/your/path
#2
13
CMAKE_SYSTEM_PROGRAM_PATH is not meant to be modified, use
使用CMAKE_SYSTEM_PROGRAM_PATH不打算修改
LIST(APPEND CMAKE_PROGRAM_PATH "c:/MyProject/Tools/mingw/bin/" ...)
#3
2
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:
您可能会把它当作一个交叉编译工具链,即使您没有像本例中那样从Linux交叉编译到Windows:
http://www.vtk.org/Wiki/CmakeMingw
http://www.vtk.org/Wiki/CmakeMingw
After you follow that guide you set the mingw toolchain at the command line when calling cmake:
在您遵循该指南之后,您在调用cmake时将mingw工具链设置在命令行:
~/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:
如果你经常使用这个,你可以创建一个别名来限制每次你想重新生成makefile时输入那个难看的-D:
alias mingw-cmake='cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake'
#1
1
Write a script file to start CMake.
编写一个脚本文件以启动CMake。
On Windows make a batch file:
在Windows上做一个批处理文件:
@echo off
set path=c:\MyProject\Tools\mingw\bin;c:\MyProject\Tools\mingw\msys\1.0\bin
"C:\Program Files\CMake 2.8\bin\cmake-gui.exe"
On Linux make a bash script:
在Linux上做一个bash脚本:
export PATH=$PATH:/your/path
#2
13
CMAKE_SYSTEM_PROGRAM_PATH is not meant to be modified, use
使用CMAKE_SYSTEM_PROGRAM_PATH不打算修改
LIST(APPEND CMAKE_PROGRAM_PATH "c:/MyProject/Tools/mingw/bin/" ...)
#3
2
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:
您可能会把它当作一个交叉编译工具链,即使您没有像本例中那样从Linux交叉编译到Windows:
http://www.vtk.org/Wiki/CmakeMingw
http://www.vtk.org/Wiki/CmakeMingw
After you follow that guide you set the mingw toolchain at the command line when calling cmake:
在您遵循该指南之后,您在调用cmake时将mingw工具链设置在命令行:
~/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:
如果你经常使用这个,你可以创建一个别名来限制每次你想重新生成makefile时输入那个难看的-D:
alias mingw-cmake='cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake'