Search code examples
cmakecygwineclipse-cdt

Using CMake with Eclipse CDT and Cygwin on Windows


For a new project we want to use CMake. We are using Eclipse CDT as IDE and Cygwin gcc.

We generated the CMakeLists.txt and followed [this tutorial (option 2)][1].

When I try to run the described Make target to generate the Makefiles with CMake, which executes

cmake -E chdir C:/projects/eclipse_ws/MyApp/Build/ cmake -G "Unix Makefiles" ../ Run CMake 

I get the error

CMake Error: The source directory "C:/projects/eclipse_ws/MyApp/Build/CMake" does not exist.

If I run the command directly from a Cygwin console it works just fine, however then I have to run make also from the Cygwin console, because the Makefiles are generated with Unix paths.

EDIT:

So I fixed this issue (see my answer below).

But I'm still having problems.

When I try to run CMake as Make target in Eclipse as suggested in the tutorial I get the following errors:

cmake -E chdir Build/ cmake -G 'Unix Makefiles' ../ 
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to [email protected] so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please send that file to [email protected].
-- Check for working C compiler: /usr/bin/gcc.exe
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to [email protected] so it can be added to cmake
-- Check for working C compiler: /usr/bin/gcc.exe -- broken
CMake Error at /usr/share/cmake-2.8.9/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "/usr/bin/gcc.exe" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles CMakeTmp

  Run Build Command:/usr/bin/make.exe "cmTryCompileExec726566634/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec726566634.dir/build.make
  CMakeFiles/cmTryCompileExec726566634.dir/build

  make[1]: Entering directory
  '/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake.exe -E cmake_progress_report
  /cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/CMakeFiles
  1

  Building C object
  CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj

  /usr/bin/gcc.exe -o
  CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj -c
  /cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/testCCompiler.c

  CMakeFiles/cmTryCompileExec726566634.dir/build.make:60: recipe for target
  'CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj' failed

  make[1]: Leaving directory
  '/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'

  make[1]: *** [CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj]
  Error 1

  Makefile:117: recipe for target 'cmTryCompileExec726566634/fast' failed

  make: *** [cmTryCompileExec726566634/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!

Seems like for some reason CMake assumes I have an MinGW environment and not Cygwin.

EDIT2 MinGW system was assumed, because a Git installation was in PATH before Cygwin and Git's uname command was used (which returns MinGW).


Solution

  • If you check "Make Target - Same as the target name" in Eclipse's Make dialog, Eclipse will add a

    Run CMake
    

    to the command (see question), which is misinterpreted by CMake. I just unchecked "Same as the target name".