1

使用我当前的CMakeLists.txt文件,我可以构建我的项目:

sourceDir>  cmake -G "MinGW Makefiles" .

从源目录。

但是我无法获得树外构建:

buildDir>  cmake -G "MinGW Makefiles"  ..\MyProg

这是我从 cmake 得到的错误:

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (MESSAGE):
  sh.exe was found in your PATH, here:

  C:/Program Files (x86)/Git/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.

  Run cmake from a shell that does not have sh.exe in your PATH.

  If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
  CMakeLists.txt:16 (project)


CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:S:/MyProg/build/CMakeFiles/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:S:/MyProg/build/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
4

3 回答 3

1

这些错误来自设置不同的环境是没有意义的。两个命令是否从完全相同的 shell 运行?此外,一旦您配置源内,您就不能进行源外构建。所以,要测试试试这个:

mkdir 新源;在此处查看您的源 mkdir ../build cd ../build cmake -G"MinGW Makefiles" ../newsource

mkdir 内源;在此处查看您的源代码 cmake -G"MinGW Makefiles" 。

从完全相同的外壳执行这两项操作。

于 2013-07-17T14:13:52.767 回答
1

我发现了一个肮脏的解决我的问题:

buildDir>  cmake -G "MinGW Makefiles"  ..\MyProg\
buildDir>  cmake -G "MinGW Makefiles"  ..\MyProg\

我第一次收到问题中显示的错误。第二次一切都按原样进行。

如果您有更好、更合乎逻辑的解决方案,请告诉我。

于 2013-07-18T10:37:36.123 回答
0

我认为您必须从 Windows PATH 环境变量中删除“MinGW\msys\1.0\bin”。

于 2013-07-17T14:11:42.180 回答