Using CMake with Eclipse CDT and Cygwin on Windows - cmake

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 cmake#www.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please send that file to cmake#www.cmake.org.
-- 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 cmake#www.cmake.org 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).

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".

Related

Simple test output - CMake Error: The source directory does not exist

When I create new project in Clion, cmake cannot find CMakeTmp directory.
Run Build Command(s):/usr/bin/cmake cmTC_df723/fast && No such file or directory
OS: Linux Mint 19 (Ubuntu based)
I have tried:
reinstalling gcc (now on version 8.3.0)
reinstalling cmake (now on version 3.15.2)
unset TMP from (CMake cannot compile test program as source directory doesnt exist)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_SYSTEM_NAME Linux)
checked permissions to ClionProject subdirectories
Error output:
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/bin/cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/gcc -G "CodeBlocks - Unix Makefiles" /home/sacha/CLionProjects/testProject
-- The C compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/gcc
CMake Error: Generator: execution of make failed. Make command was: /usr/bin/cmake cmTC_df723/fast &&
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/local/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/usr/bin/gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/sacha/CLionProjects/testProject/cmake-build-release-system/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/cmake cmTC_df723/fast && No such file or directory
Generator: execution of make failed. Make command was: /usr/bin/cmake cmTC_df723/fast &&
Any help or directions appreciated, thanks!
The error message
CMake Error: Generator: execution of make failed.
signals, that something wrong with CMake settings or its generator.
In the given case you have additional message
Make command was: /usr/bin/cmake cmTC_df723/fast &&
which means that cmake is run as a Make command.
This is wrong: cmake and make commands are not interchangeable.
Would you inspect the very first command line, you will find the source of that problem:
-DCMAKE_MAKE_PROGRAM=/usr/bin/cmake
Exactly it sets cmake executable for Make command. You need to fix that line (e.g. in CLion settings).

cmake error: cc fails because no input files

hello I just installed cmake 3.6.2 (the one that comes with cygwin) and I got an error message trying to build llvm, saying that the build failed because cc was unable to find the input file. I've seen lots of postings about a similar problem but in this case, cc is right - the input file does not in fact exist, as I confirmed by checking the directory CMakeTmp. I don't have any spaces in the cmake installation directory tree which is typically the problem. So it looks like cmake has screwed up somewhere. Any ideas?
$ cmake $C/ProgramFiles/llvm-7.0.1/src
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /cygdrive/c/ProgramFiles/Haskell Platform/8.4.3/mingw/bin/cc.exe
-- Check for working C compiler: /cygdrive/c/ProgramFiles/Haskell Platform/8.4.3/mingw/bin/cc.exe
-- Check for working C compiler: /cygdrive/c/ProgramFiles/Haskell Platform/8.4.3/mingw/bin/cc.exe -- broken
CMake Error at /usr/share/cmake-3.6.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/cygdrive/c/ProgramFiles/Haskell
Platform/8.4.3/mingw/bin/cc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_d77a9/fast"
/usr/bin/make -f CMakeFiles/cmTC_d77a9.dir/build.make
CMakeFiles/cmTC_d77a9.dir/build
make[1]: Entering directory
'/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d77a9.dir/testCCompiler.c.o
"/cygdrive/c/ProgramFiles/Haskell Platform/8.4.3/mingw/bin/cc.exe" -o
CMakeFiles/cmTC_d77a9.dir/testCCompiler.c.o -c
/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeTmp/testCCompiler.c
cc.exe: error:
/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeTmp/testCCompiler.c:
No such file or directory
cc.exe: fatal error: no input files
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_d77a9.dir/build.make:66:
CMakeFiles/cmTC_d77a9.dir/testCCompiler.c.o] Error 1
make[1]: Leaving directory
'/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_d77a9/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:50 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/ProgramFiles/llvm-7.0.1/build/CMakeFiles/CMakeError.log".
So I installed cmake from the cmake website and that works fine, so it definitely looks like a problem with the cygwin cmake. I would report this bug to cygwin if there was a way to do so

Trying to use JetBrains CLion, but Cmake - c++ compiler broken after cygwin install

I have been trying to get JetBrains CLion IDE working, but I am running into a problem with Cmake and none of my research online has been helpful. I installed cygwin with the necessary packages (as stated here - gcc/g++, cmake, make, gdb). When I open up CLion and go into Settings (I'm running Windows 10) under Build>Toolchains>Debugger everything has a check next to it, so it seems like CLion has found everything alright, but when I look in the Debugger window I get the following error:
"C:\Users\Lucas Lofaro\.CLion2016.3\system\cygwin_cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview"
-- The CXX compiler identification is GNU 5.3.0
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- broken
CMake Error at /cygdrive/c/Users/Lucas Lofaro/.CLion2016.3/system/cygwin_cmake/share/cmake-3.6.2/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_96921/fast"
/usr/bin/make -f CMakeFiles/cmTC_96921.dir/build.make
CMakeFiles/cmTC_96921.dir/build
make[1]: Entering directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -c
"/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
Linking CXX executable cmTC_96921.exe
"/cygdrive/c/Users/Lucas
Lofaro/.CLion2016.3/system/cygwin_cmake/bin/cmake.exe" -E cmake_link_script
CMakeFiles/cmTC_96921.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import
CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -o cmTC_96921.exe
-Wl,--out-implib,libcmTC_96921.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
CMakeFiles/cmTC_96921.dir/build.make:97: recipe for target 'cmTC_96921.exe'
failed
make[1]: *** [cmTC_96921.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_96921/fast' failed
make: *** [cmTC_96921/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeError.log".
I've also added the cygwin bin directory to my Path environment variable, but I am really at a loss as to what to do next. Something isn't linking up and I don't want to start digging around in Cmake files without a better understanding of what's going on. Any guidance would be much appreciated. Please let me know if I can provide any additional information.
It turns out that the cmake, make, and g++ packages were installed but not updated to their most recent versions. Rerunning cygwin installer solved my problem and everything now compiles fine.

Unknown CMake command "CHECK_INCLUDE_FILE_CXX"

I tried running cmake to generate the build tools for linux on vmime with the latest source from git hub, it generated the following errors. Thoughts??
vmime$ /usr/local/bin/cmake -G "Unix Makefiles"
CMake Error at CMakeLists.txt:20 (INCLUDE):
include could not find load file:
CheckIncludeFileCxx
-- Build type: Debug
CMake Error at CMakeLists.txt:452 (CHECK_INCLUDE_FILE_CXX):
Unknown CMake command "CHECK_INCLUDE_FILE_CXX".
-- Configuring incomplete, errors occurred!
In your CMakeLists.txt at line 20, you have
include(CheckIncludeFileCxx)
This should be
include(CheckIncludeFileCXX)
^^--- Uppercase
Once CheckIncludeFileCXX is properly included, the error on line 452 should also disappear, since the file defines the function CHECK_INCLUDE_FILE_CXX.
It has probably only been tested on Windows; since Windows filenames are case-insensitive this would have worked.

CMake cannot compile test program as source directory doesnt exist

all. I'm trying to use cmake for compile some android code with android toolchain on Windows 7x64.
when i call cmake as following
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=android.cmake 1>!cmake.log 2>!cmake.error.log
I run this command from Administrator console and get following output:
!cmake.log
-- The C compiler identification is GNU 4.6.0
-- The CXX compiler identification is GNU 4.6.0
-- Check for working C compiler: c:/cygwin/usr/local/android-toolchain-r8ea9/bin/arm-linux-androideabi-gcc.exe
-- Check for working C compiler: c:/cygwin/usr/local/android-toolchain-r8ea9/bin/arm-linux-androideabi-gcc.exe -- broken
-- Configuring incomplete, errors occurred!
!cmake.error.log
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"c:/cygwin/usr/local/android-toolchain-r8ea9/bin/arm-linux-androideabi-gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/PDK_BUILD/openssl/CMakeFiles/CMakeTmp
Run Build Command:C:/PROGRA~2/CMAKE2~1.8/bin/cmake.exe
"cmTryCompileExec333575975/fast"
CMake Error: The source directory
"C:/PDK_BUILD/openssl/CMakeFiles/CMakeTmp/cmTryCompileExec333575975/fast"
does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
I granted adninistrator rights for cmake.exe itself, cleared read-only attributes from CMakeFiles folder and disabled anti-virus but still not worked.
It looks like you are running into CMake Bug 0013131. This comment suggests that using unset TMP should fix the problem. Don't forget to delete the CMakeCache.txt and CMakeFiles folders (or the entire build tree when using out-of-source builds), before retrying.