MantisBT - CMake
View Issue Details
0013313CMakeCMakepublic2012-06-18 09:312012-08-09 19:39
Eric Beuque 
Alex Neundorf 
highminoralways
closedfixed 
Win32WindowsWindows 7
CMake 2.8.8 
CMake 2.8.9CMake 2.8.9 
0013313: [Eclipse CDT] The MinGW include pathentry are not added to the .cproject
I'm using a Windows 7 under Virtualbox from a Linux host.

When building a simple project with cmake to generate an Eclipse project, the include path are not added to the .cproject.

This has effect that all c++ standard headers are not found by eclipse, but the compilation success.

A strange thing is that it works depending on the sources folder:
- In a directory like C:\Users\Me\Devel\cmaketest: it doesn't work
- In a directory like C:\Me\cmaketest: it doesn't work
- In a directory like E:\Devel\cmaketest: it works

The only difference I see is the filesystem type:
- E: is a shared folder by VBox from the host which have a filesystem type Ext4
- C: is a standard NTFS partition
- Add to PATH the cmake and mingw bin path.
- Unzip my archive
- Run bootstrap.bat
I attach the two generated .cproject.
No tags attached.
related to 0009122closed Alex Neundorf Eclipse CDT4 generator fails to determine include path when locale not in English 
zip cmaketest.zip (90,019) 2012-06-18 09:31
https://public.kitware.com/Bug/file/4359/cmaketest.zip
? bad.cproject (22,209) 2012-06-18 09:33
https://public.kitware.com/Bug/file/4360/bad.cproject
? good.cproject (22,812) 2012-06-18 09:34
https://public.kitware.com/Bug/file/4361/good.cproject
txt gcc-result-good.txt (10,189) 2012-06-19 02:56
https://public.kitware.com/Bug/file/4365/gcc-result-good.txt
txt gcc-result-bad.txt (10,456) 2012-06-19 02:57
https://public.kitware.com/Bug/file/4366/gcc-result-bad.txt
? CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake (4,757) 2012-06-25 17:11
https://public.kitware.com/Bug/file/4370/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
Issue History
2012-06-18 09:31Eric BeuqueNew Issue
2012-06-18 09:31Eric BeuqueFile Added: cmaketest.zip
2012-06-18 09:33Eric BeuqueFile Added: bad.cproject
2012-06-18 09:34Eric BeuqueFile Added: good.cproject
2012-06-18 16:38Alex NeundorfAssigned To => Alex Neundorf
2012-06-18 16:38Alex NeundorfStatusnew => assigned
2012-06-18 16:43Alex NeundorfNote Added: 0029733
2012-06-19 02:56Eric BeuqueFile Added: gcc-result-good.txt
2012-06-19 02:57Eric BeuqueFile Added: gcc-result-bad.txt
2012-06-19 03:00Eric BeuqueNote Added: 0029738
2012-06-19 03:00Eric BeuqueNote Edited: 0029738bug_revision_view_page.php?bugnote_id=29738#r687
2012-06-19 05:58Eric BeuqueNote Edited: 0029738bug_revision_view_page.php?bugnote_id=29738#r688
2012-06-20 16:27Alex NeundorfNote Added: 0029786
2012-06-20 16:39Alex NeundorfNote Edited: 0029786bug_revision_view_page.php?bugnote_id=29786#r699
2012-06-21 03:07Eric BeuqueNote Added: 0029793
2012-06-21 16:06Alex NeundorfNote Added: 0029805
2012-06-25 03:52Eric BeuqueNote Added: 0029818
2012-06-25 14:53Alex NeundorfNote Added: 0029833
2012-06-25 17:11Alex NeundorfFile Added: CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
2012-06-25 17:12Alex NeundorfNote Added: 0029834
2012-06-25 17:12Alex NeundorfRelationship addedrelated to 0009122
2012-06-26 03:22Eric BeuqueNote Added: 0029835
2012-06-27 17:43Alex NeundorfNote Added: 0029850
2012-06-27 17:43Alex NeundorfStatusassigned => closed
2012-06-27 17:43Alex NeundorfResolutionopen => fixed
2012-08-09 19:39David ColeFixed in Version => CMake 2.8.9
2012-08-09 19:39David ColeTarget Version => CMake 2.8.9

Notes
(0029733)
Alex Neundorf   
2012-06-18 16:43   
Please run the following command for your mingw C++ compiler and post the output here.
Simply do "touch dummy.cpp" and then run the command:
$ gcc -v -E -x c++ -dD dummy.cpp

This is what is executed by cmake, and then cmake tries to extract the include dirs from there.

Alex
(0029738)
Eric Beuque   
2012-06-19 03:00   
(edited on: 2012-06-19 05:58)
OK this is maybe a locale issue, I don't know why, but i got a different output in a different locale depending on the directory, where i compile. The wrong output has a french locale and the good has an english locale.

See result of the command gcc-result-good.txt and gcc-result-bad.txt.

So this is probably a problem between the cmake parser and the french locale.

(0029786)
Alex Neundorf   
2012-06-20 16:27   
(edited on: 2012-06-20 16:39)
Oui :-)

The cmake module which parses the output already tries to set it to default (C) by setting the LC_ALL, LC_MESSAGES and LANG environment variables to "C".

Can you find out manually which environment variables have to be set to what to get plain english output ?
Maybe also LANGUAGE ? Or LOCALE ?
Maybe "C" doesn't work under Windows, but "en" does ?

(0029793)
Eric Beuque   
2012-06-21 03:07   
Actually, SET LANG=C or "C" works fine. It also working if i try with LC_ALL, LC_MESSAGES of LANGUAGE variable, but not with LOCALE.

I still don't understand why i got a different default locale on a different directory.

*************************************************
C:\>gcc -v -E -x c++ -dD dummy.cpp
gcc: erreur: dummy.cpp: No such file or directory
gcc: attention : '-x c++' after last input file has no effect
Utilisation des specs internes.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configuré avec: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs
 --build=mingw32 --prefix=/mingw
Modèle de thread: win32
gcc version 4.6.2 (GCC)

E:\>gcc -v -E -x c++ -dD dummy.cpp
gcc: error: dummy.cpp: No such file or directory
gcc: warning: '-x c++' after last input file has no effect
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-lib
s --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)
*************************************************


C:\Users\ebeuque\Devel\testing.mingw32>gcc -v -E -x c++ -dD dummy.cpp
gcc: erreur: dummy.cpp: No such file or directory
gcc: attention : '-x c++' after last input file has no effect
Utilisation des specs internes.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configuré avec: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs
 --build=mingw32 --prefix=/mingw
Modèle de thread: win32
gcc version 4.6.2 (GCC)

C:\Users\ebeuque\Devel\testing.mingw32>set LANG=C

C:\Users\ebeuque\Devel\testing.mingw32>gcc -v -E -x c++ -dD dummy.cpp
gcc: error: dummy.cpp: No such file or directory
gcc: warning: '-x c++' after last input file has no effect
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-lib
s --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)

C:\Users\ebeuque\Devel\testing.mingw32>set LANG=fr

C:\Users\ebeuque\Devel\testing.mingw32>gcc -v -E -x c++ -dD dummy.cpp
gcc: erreur: dummy.cpp: No such file or directory
gcc: attention : '-x c++' after last input file has no effect
Utilisation des specs internes.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configuré avec: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs
 --build=mingw32 --prefix=/mingw
Modèle de thread: win32
gcc version 4.6.2 (GCC)

C:\Users\ebeuque\Devel\testing.mingw32>set LANG=en

C:\Users\ebeuque\Devel\testing.mingw32>gcc -v -E -x c++ -dD dummy.cpp
gcc: error: dummy.cpp: No such file or directory
gcc: warning: '-x c++' after last input file has no effect
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-lib
s --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)
(0029805)
Alex Neundorf   
2012-06-21 16:06   
This is with cmake 2.8.8, or are you using some older version ?

The thing is, in the file Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake the LC_ALL, LC_MESSAGES and LANG environment variables are all set to "C".
Have a look at this file, and maybe play around with it to figure out what's going wrong (I don't have a Windows around).
(0029818)
Eric Beuque   
2012-06-25 03:52   
Yes, this cmake 2.8.8.

I found the problem, in your Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake.

The following code doesn't work:

SET(_orig_lc_all $ENV{LC_ALL})
SET(_orig_lc_messages $ENV{LC_MESSAGES})
SET(_orig_lang $ENV{LANG})
IF(_orig_lc_all)
  SET(ENV{LC_ALL} C)
ENDIF()
IF(_orig_lc_messages)
  SET(ENV{LC_MESSAGES} C)
ENDIF()
IF(_orig_lang)
  SET(ENV{LANG} C)
ENDIF()

The fact is i have none of these environment variables defined on my system, so the if condition always fail, and the environment variable is never set. If define an environment variable for example LANG on my system, it works, my include are correctly set in the .cproject.

Maybe you should define one of these if none is defined, and undef it when no more needed.
(0029833)
Alex Neundorf   
2012-06-25 14:53   
So it works if you set LANG to "C" ?
(0029834)
Alex Neundorf   
2012-06-25 17:12   
Can you please verify that the attached CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake makes it work for you ?

We have to hurry a bit if we still want to have this in 2.8.9.

Alex
(0029835)
Eric Beuque   
2012-06-26 03:22   
Yes, your file works fine, i correctly retrieve my includes in the .cproject.

Thank you.
(0029850)
Alex Neundorf   
2012-06-27 17:43   
I merged the fix in the EclipseFixIncludeDirDetectionMinGW branch into next, I hope it will still make it into 2.8.9.