質問

With my current CMakeLists.txt files, I can build my project with:

sourceDir>  cmake -G "MinGW Makefiles" .

from the source directory.

However I cannot get an out-of-tree build:

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

This is the error I get from 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!
役に立ちましたか?

解決 2

I found a dirty fix to my problem:

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

The first time I get the error shown in my question. The second time everything goes as it should.

Let me know if you have a better, more logic solution.

他のヒント

That does not make sense those errors come from the environment being setup different. Are both commands being run from the exact same shell? Also, once you configure in-source, you can not do an out of source build. So, to test try this:

mkdir newsource; checkout your source here mkdir ../build cd ../build cmake -G"MinGW Makefiles" ../newsource

mkdir insource; checkout out your source here cmake -G"MinGW Makefiles" .

Do both of these from the exact same shell.

I think you have to remove "MinGW\msys\1.0\bin" from your windows PATH environment variable.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top