I'm trying to generate an eclipse .project and .cproject from an existing cmake file. Running cmake from the project root I tried adding to the root CMakeLists.txt
set(CMAKE_ECLIPSE_VERSION=4.2) which apparently might do nothing as it is a local variable, not the global env variable, if i understand correctly.
Trying to add the flag to the commandline like this:
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.2 .
Produces the following warning. So how does one let cmake know the eclipse version?
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
I checked the .project file and it seems to be using cdt 4. Pretty old.
kesten
I had the same problem and after looking at CMake's code I noticed that the actual variable used to get the Eclipse's version is named _ECLIPSE_VERSION (starting with underscore) and not CMAKE_ECLIPSE_VERSION. Here's what the code looks like:
cmake -G"Eclipse CDT4 - Unix Makefiles" -D_ECLIPSE_VERSION=4.2 .
That worked for me!
EDIT: Older versions of CMake don't recognise Eclipse 4.2 (which uses CDT 8.1) but does recognize 3.7 (which uses CDT 8.0). I used -D_ECLIPSE_VERSION=3.7 and Juno picked up well the project configuration (previously I had unresolved inclusions due to incompatibility of the CDT4 files generated by default). As pointed out by m3tikn0b, newer versions of CMake do recognize until Eclipse Kepler 4.3.
There is a bug in CMake. See 0014422: CMAKE_ECLIPSE_VERSION is not taken into account. THe issue tracker says it will be corrected in cmake 2.8.13.
same problem here. After search i found the following solution:
previously tried:
cmake -G"Eclipse CDT4 - Unix Makefiles" -D_ECLIPSE_VERSION=4.2 ../src
and it doesn't work. Then i tried:
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.2 ../src
This worked for me.. I hope it helps.
Related
I am trying to create a simple helloworld Eclipse CDT project using the CMake GUI. The CMake file looks like this:
cmake_minimum_required(VERSION "3.11.1")
project("HelloWorld")
add_executable("HelloWorldMain" "Main.cpp")
install(TARGETS "${PROJECT_NAME}" DESTINATION bin)
install(FILES "Main.cpp" DESTINATION src)
The only c/c++ compiler I have is MSVC so I set that as the CMAKE_CXX_COMPILER but I get an error when configuring as shown here:
I know this file exists, but how do I get it to find it?
I ended up not using the GUI. Instead I used the VS x64 Native Tools Command Prompt then ran the cmake command:
cmake -G "Eclipse CDT4 - NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../
For some reason it forces -G Ninja when I try to build within eclipse. I would prefer Eclipse just not specify the -G option to cmake, but I can't figure out how to configure Eclipse to do that.
For exampe, this in my console window:
Building in: /home/bgass/eclipse-workspace/scomlib/build/default
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
CMake Error: Error: generator : Ninja
Does not match the generator used previously: Unix Makefiles
Either remove the CMakeCache.txt file or choose a different binary directory.
cmake --build . -- -v
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Build complete (0 errors, 0 warnings): /home/bgass/eclipse-workspace/scomlib/build/default
In a terminal it works just fine without the generator specified.
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bgass/eclipse-workspace/scomlib/build/default
I always execute cmake outside eclipse and open the generated eclipse project in Eclipse.
use -G "Eclipse CDT4 - Unix Makefiles" to specify Eclipse as the generator.
Following are the full set of Eclipse generators.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Type in cmake --help to see what generators are supported by your specific cmake version.
I get the following when trying to build a makefile in eclipse neon:
Error: Program "make" not found in PATH
followed by my full path, which begins
Error: Program "make" not found in PATH PATH=[C:/Program
Files/Java/jre1.8.0_141/bin/server;C:/Program
Files/Java/jre1.8.0_141/bin;C:/Program
Files/Java/jre1.8.0_141/lib/amd64;C:\msys64\mingw64\bin;
(it continues after this...)
However, cmake is definitely present in C:\msys64\mingw64\bin.
How can I fix this so eclipse is using the cmake.exe?
Eclipse is looking for make program not cmake. To install make on MSYS2 use the command pacman -S make. CMake is a build system generator that creates Makefiles for you. But it does not build the Makefiles itself it uses an installed make for that.
I've followed the steps on the Cygwin wiki for updating my version of gcc. Now I have two installations of gcc in Cygwin: 3.4 in /bin and 4.7 in /usr/local/bin. Now, in Eclipse the only way to use it seems to be changing the invocation command from g++ to C:/cygwin/usr/local/bin/g++, and this has to be done for all projects. Is there any way to make Eclipse CDT use this by default? I have changed the Path environment variable, and typing g++ --version in a command line gives 4.7, but building a project in Eclipse with --version still gives 3.4
I've been unable to get the wonderful Eclipse Colorer plugin to work with my current copy of Eclipse (Helios 64 bit). It installs ok but whenever I attempt to open a source file I get this error:
Error in initialization of native part of the Colorer library. This can be caused by absent net_sf_colorer.dll (libnet_sf_colorer.so) library in paths of java machine. Or, colorer can't find catalog.xml file, which must be placed in '%PLUGIN_DIR%'/colorer/catalog.xml'
Could not initialize class net.sf.colorer.ParserFactory
It has nothing to do with the version of Eclipse. Try a 32-bit Version, AFAIK Eclipse Colorer has no support for 64-bit.
I actually managed to make it run on a 64bit eclipse (indigo) by compiling my own version of Colorer. Once you know it's pretty easy: first you get the svn version:
svn co https://colorer.svn.sourceforge.net/svnroot/colorer/trunk/ trunk
cd trunk/eclipsecolorer/libnative
mkdir objs # not sure why make cannot do that..
make -f makefile.macos_64
Then you must create a new x86_64 directory in your eclipse plugin, and copy the lib there. In my case it was:
mkdir /Applications/eclipse/plugins/net.sf.colorer_0.9.8/os/macosx/x86_64
cp libnet_sf_colorer.jnilib /Applications/eclipse/plugins/net.sf.colorer_0.9.8/os/macosx/x86_64/