View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013606CMakeCMakepublic2012-10-25 08:192013-10-07 10:04
ReporterMika Fischer 
Assigned ToPeter Kuemmel 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSArchOS Version
Product VersionCMake 2.8.9 
Target VersionFixed in VersionCMake 2.8.11 
Summary0013606: Ninja: Eclipse Generator wants to run c++ to determine system include paths before c++ compiler is determined by cmake
DescriptionI added some debugging output to CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake and get the following output from cmake -G "Eclipse CDT4 - Ninja" <srcdir>:

-------------------------------------------------------------------------
-- The C compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
CMAKE_C_COMPILER: "/usr/bin/gcc"
CMAKE_C_COMPILER_ID: "GNU"
Running c system include detection: /usr/bin/gcc -v -E -x c -dD dummy
CMAKE_CXX_COMPILER: ""
CMAKE_CXX_COMPILER_ID: ""
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
CMAKE_CXX_COMPILER set to "/usr/bin/c++"
-- The CXX compiler identification is GNU 4.7.2
CMAKE_CXX_COMPILER_ID set to "GNU"
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-------------------------------------------------------------------------

So somehow the Eclipse generator wants to determine the include paths of the C++ compilers before it's even detected by CMake. This works for C, since CMAKE_C_COMPILER and CMAKE_C_COMPILER_ID are set at that point (see debug output shown above). However this is not the case for CMAKE_CXX_COMPILER and CMAKE_CXX_COMPILER_ID. Therefore the generator can't run the C++ compiler and thus the project file misses the system includes for C++, breaking things everywhere...
Steps To ReproduceGenerate an Eclipse project file of a C++ project.
Additional InformationI use the following as aworkaround:

cmake -D CMAKE_CXX_COMPILER_ID:STRING=GNU -D CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ -G "Eclipse CDT4 - Ninja"

-------------------------------------------------------------------------
-- The C compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
CMAKE_C_COMPILER: "/usr/bin/gcc"
CMAKE_C_COMPILER_ID: "GNU"
Running c system include detection: /usr/bin/gcc -v -E -x c -dD dummy
CMAKE_CXX_COMPILER: "/usr/bin/c++"
CMAKE_CXX_COMPILER_ID: "GNU"
Running c++ system include detection: /usr/bin/c++ -v -E -x c++ -dD dummy
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
CMAKE_CXX_COMPILER set to "/usr/bin/c++"
-- The CXX compiler identification is GNU
CMAKE_CXX_COMPILER_ID set to "GNU"
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-------------------------------------------------------------------------
TagsNo tags attached.
Attached Filestxt file icon CMakeLists.txt [^] (231 bytes) 2013-02-16 10:24 [Show Content]

 Relationships
related to 0013903closedPeter Kuemmel Ninja: Problems with Windows CE 

  Notes
(0031404)
Alex Neundorf (developer)
2012-11-03 14:25

I can't reproduce your problem.
This is the logging output I get:

~/tests/build-hello-eclipse-2$ cmake -G "Eclipse CDT4 - Unix Makefiles" ../hello
-- The C compiler identification is GNU 4.5.2
-- The CXX compiler identification is GNU 4.5.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- ********* c -/usr/bin/cc-
-- *********** c++ -/usr/bin/c++-
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done

The "*****" output is from CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake, from the two branches where the _compilerExecutable variable is set.
It looks fine to me. Also the CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS and CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS as they are stored in my CMakeCache.txt look good.

Can you provide more information ?
(0031405)
Mika Fischer (reporter)
2012-11-03 14:49

Yes, with -G "Eclipse CDT4 - Unix Makefiles" things work as expected. Sorry, I hadn't even tried with makefiles before...

The error does occur with -G "Eclipse CDT4 - Ninja", however (tested with CMake 2.8.9 and 2.8.10).
(0031411)
Alex Neundorf (developer)
2012-11-04 08:28

Peter, since this happens only with Ninja, can you please have a look at it ?
(0032312)
Peter Kuemmel (developer)
2013-02-16 09:14

Could not reproduce:

CMakeLsists.txt:
project(x CXX)

$ cmake -G "Eclipse CDT4 - Ninja" ..
-- The CXX compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
g++ : /usr/bin/c++
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
(0032313)
Mika Fischer (reporter)
2013-02-16 10:14

Funny, you found the one case where it actually works :)

The trick is the CXX in the project call. If you change it to "project(x C CXX)" it still fails here.

Further we don't use any languages in the call to project but let CMake figure out the languages used by the project on its own. In that case it also fails.

We can't even use this as a workaround, since if we use "CXX C" it will have the same problem determining the system includes for the C compiler.

So in a nutshell, it only correctly determines the system includes for the *first* language in the call to project() or for C if no languages are passed to project().
(0032314)
Peter Kuemmel (developer)
2013-02-16 10:28

Uploaded CMakeLists.txt also doesn't specifies the languages.
It only prints gcc but compiles the c++ file without errors:

$ cmake -G"Eclipse CDT4 - Ninja" ..
-- The C compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
gcc : /usr/bin/gcc
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- The CXX compiler identification is GNU 4.7.2
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
CMake Warning in CMakeLists.txt:
  The build directory is a subdirectory of the source directory.

  This is not supported well by Eclipse. It is strongly recommended to use a
  build directory which is a sibling of the source directory.


-- Generating done
-- Build files have been written to: /home/synth/sandbox/lyx/_b
$ ninja -v
[1/2] /usr/bin/c++ -MMD -MT CMakeFiles/foo.dir/foo.cpp.o -MF "CMakeFiles/foo.dir/foo.cpp.o.d" -o CMakeFiles/foo.dir/foo.cpp.o -c ../foo.cpp
[2/2] : && /usr/bin/c++ CMakeFiles/foo.dir/foo.cpp.o -o foo -rdynamic && :


Could you post a complete examples which reproduces your error?
(0032316)
Mika Fischer (reporter)
2013-02-16 10:41

Yes, it compiles here as well. The issue is that the system include paths for C++ are not included in the Eclipse project file. Check the generated .cproject for something like:
<pathentry include="/usr/include/c++/4.7.2" kind="inc" path="" system="true"/>

Compiling always worked. But the Eclipse project file is practically unusable because simple things like std::string and std::vector cannot be resolved by the Eclipse indexer. So is shows large parts of the code as errors even though they compile fine.

Your minimal example is fine to trigger the error:

-----------------------------------------------------------------------

% echo "project(x CXX)" > ../CMakeLists.txt
% cmake -G "Eclipse CDT4 - Ninja" ..
-- The CXX compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
In /usr/share/cmake-2.8/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake:91
CMAKE_C_COMPILER_ID: ""
CMAKE_CXX_COMPILER_ID: "GNU"
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
[...]
% grep "include/c++" .cproject
<pathentry include="/usr/include/c++/4.7.2" kind="inc" path="" system="true"/>
<pathentry include="/usr/include/c++/4.7.2/x86_64-unknown-linux-gnu" kind="inc" path="" system="true"/>
<pathentry include="/usr/include/c++/4.7.2/backward" kind="inc" path="" system="true"/>

-----------------------------------------------------------------------

% echo "project(x C CXX)" > ../CMakeLists.txt
% cmake -G "Eclipse CDT4 - Ninja" ..
-- The C compiler identification is GNU 4.7.2
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
In /usr/share/cmake-2.8/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake:91
CMAKE_C_COMPILER_ID: "GNU"
CMAKE_CXX_COMPILER_ID: ""
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- The CXX compiler identification is GNU 4.7.2
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
[...]
% grep "include/c++" .cproject
[grep will not find any matches]

-----------------------------------------------------------------------
(0032367)
kesten (reporter)
2013-02-24 09:19

I'm running on a mac with a clang toolchain trying to generate an Eclipse project from a cmake project.
The strategy to locate include directories also fail in this use case.

I'm trying
$ cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.2 -D CMAKE_BUILD_TYPE=Debug -D MACOSX=1 -D CMAKE_C_COMPILER=/usr/bin/cc -D CMAKE_CXX_COMPILER=/usr/bin/c++ .

The CMAKE_ECLIPSE_VERSION flag has no effect. I still get the "Could not determine Eclipse version, " message.

It seems the method of determining include dirs (dummy run gcc and parse the output) is brittle. in CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake

  IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel)
    _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs _defines)
    SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories")
    SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "CXX compiler system defined macros")
  ENDIF ()

So it fails without warning for CMAKE_CXX_COMPILER_ID = Clang as it is for me.

Hopefully the fix for the Ninja issue will also include a fix for this issue. I'm fairly new to cmake, but shouldn't the Find_* modules be used to get the stl etc directories instead of this "run gcc and parse the output" strategy?

kesten
(0032368)
Mika Fischer (reporter)
2013-02-24 09:38

kesten, this is an unrelated issue. The problem, as you found out yourself, is that CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake only does something for GCC and ICC.

So I would recommend you open a separate bug report for your issue. If you know the flags that make clang print the system include directories, it should also be relatively easy to create a patch for CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake that makes it work with clang.
(0032369)
Alex Neundorf (developer)
2013-02-24 11:33

This should work in master for clang, see 0013823 .
Let me know if it doesn't.
(0032430)
kesten (reporter)
2013-03-03 11:03

Upgrading to 2.8.10.2 definitely got me past some issues. However, I'm still finding a lot of errors of "Symbol X not found" even for things like std::cout .

Also, I was getting an error about "not a recognized executeable" which seemed to go away when I set the binary parser to Mach O 64 instead of Mach O (deprecated).
Perhaps the project file shouldn't default to the deprecated parser.

I've started a new issue as Mika suggested comlete with photos and videos of my current state of affairs. I'll do up a nice How To if i can get the project successfully loaded (with all the links respected)

Link to the new issue:
http://public.kitware.com/Bug/view.php?id=13970 [^]
(0032547)
Peter Kuemmel (developer)
2013-03-09 05:35

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=751f712e1ac936afb42acc49f1f19c768d3229b5 [^]

Could you test again?

Latest binaries you could download here
http://www.cmake.org/files/dev/ [^]
(0032626)
Mika Fischer (reporter)
2013-03-14 06:17

That has fixed the issue for me, thanks!
(0034010)
Robert Maynard (manager)
2013-10-07 10:04

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-10-25 08:19 Mika Fischer New Issue
2012-10-25 14:46 Alex Neundorf Assigned To => Alex Neundorf
2012-10-25 14:46 Alex Neundorf Status new => assigned
2012-11-03 14:25 Alex Neundorf Note Added: 0031404
2012-11-03 14:49 Mika Fischer Note Added: 0031405
2012-11-04 08:28 Alex Neundorf Note Added: 0031411
2012-11-04 08:28 Alex Neundorf Assigned To Alex Neundorf => Peter Kuemmel
2012-11-04 08:28 Alex Neundorf Summary Eclipse Generator wants to run c++ to determine system include paths before c++ compiler is determined by cmake => Ninja: Eclipse Generator wants to run c++ to determine system include paths before c++ compiler is determined by cmake
2013-02-09 06:19 Peter Kuemmel Relationship added related to 0013903
2013-02-16 09:14 Peter Kuemmel Note Added: 0032312
2013-02-16 10:14 Mika Fischer Note Added: 0032313
2013-02-16 10:24 Peter Kuemmel File Added: CMakeLists.txt
2013-02-16 10:28 Peter Kuemmel Note Added: 0032314
2013-02-16 10:41 Mika Fischer Note Added: 0032316
2013-02-24 09:19 kesten Note Added: 0032367
2013-02-24 09:38 Mika Fischer Note Added: 0032368
2013-02-24 11:33 Alex Neundorf Note Added: 0032369
2013-03-03 11:03 kesten Note Added: 0032430
2013-03-09 05:35 Peter Kuemmel Note Added: 0032547
2013-03-14 06:17 Mika Fischer Note Added: 0032626
2013-03-15 16:39 Peter Kuemmel Status assigned => resolved
2013-03-15 16:39 Peter Kuemmel Fixed in Version => CMake 2.8.11
2013-03-15 16:39 Peter Kuemmel Resolution open => fixed
2013-10-07 10:04 Robert Maynard Note Added: 0034010
2013-10-07 10:04 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team