使用我当前的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!
答案 0 :(得分:1)
这些错误来自于设置不同的环境,这是没有意义的。这两个命令是从完全相同的shell运行的吗?此外,一旦配置了in-source,就无法进行源代码构建。所以,试试这个:
mkdir newsource;在这里结帐 mkdir ../build cd ../build cmake -G“MinGW Makefiles”../ newsource
mkdir insource;在这里结帐你的来源 cmake -G“MinGW Makefiles”。
从完全相同的shell中执行这两个操作。
答案 1 :(得分:1)
我找到了解决问题的简单方法:
buildDir> cmake -G "MinGW Makefiles" ..\MyProg\
buildDir> cmake -G "MinGW Makefiles" ..\MyProg\
我第一次收到问题中显示的错误。第二次一切都按照预期进行。
如果您有更好的逻辑解决方案,请告诉我。
答案 2 :(得分:0)
我认为你必须删除" MinGW \ msys \ 1.0 \ bin"从你的Windows PATH环境变量。