MantisBT - CMake
View Issue Details
0014654CMakeCMakepublic2013-12-16 14:282014-04-01 03:58
jschueller 
 
normalminoralways
closedwon't fix 
GNU/Linuxarchlinuxx86_64
CMake 2.8.12.1 
 
0014654: mingw -isystem flag c header float.h conflict
When including the UseQt4 module combined with cross-compiling with mingw64,
cmake uses these includes (read in the .rsp file):
-isystem /usr/i686-w64-mingw32/include -isystem /usr/i686-w64-mingw32/include/QtGui -isystem /usr/i686-w64-mingw32/include/QtCore

... which prevent from using defines like DBL_EPSILON in float.h:
/usr/bin/i686-w64-mingw32-g++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG @CMakeFiles/main.dir/includes_CXX.rsp -o CMakeFiles/main.dir/main.cxx.obj -c .../main.cxx
...
error: ‘DBL_EPSILON’ was not declared in this scope

If I remove the -isystem flag, it builds fine.
The -isytem seems to come from
/usr/share/cmake-2.8/Modules/Compiler/GNU.cmake:55: set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")

The minimal cmakelist using useqt4:

cmake_minimum_required ( VERSION 2.8 )
project ( mingw-test CXX )
find_package ( Qt4 REQUIRED QtCore)
include ( ${QT_USE_FILE} )
add_executable(main main.cxx)

Define a main.cxx:

#include <iostream>
#include "float.h"

int main( int argc, char **argv )
{
  std::cout <<DBL_EPSILON<<std::endl;
  return 0;
}


Also non-working from c:
#include <stdio.h>
#include <float.h>

int main() {
printf("%g", FLT_EPSILON);
return 0;
}
No tags attached.
Issue History
2013-12-16 14:28jschuellerNew Issue
2013-12-18 11:32Brad KingAssigned To => Stephen Kelly
2013-12-18 11:32Brad KingStatusnew => assigned
2013-12-18 13:44jschuellerNote Added: 0034796
2013-12-18 18:56Stephen KellyNote Added: 0034814
2013-12-18 18:56Stephen KellyAssigned ToStephen Kelly =>
2013-12-18 18:56Stephen KellyStatusassigned => new
2013-12-18 18:56Stephen KellySteps to Reproduce Updatedbug_revision_view_page.php?rev_id=1339#r1339
2013-12-19 09:50Brad KingNote Added: 0034816
2013-12-19 10:47Stephen KellyNote Added: 0034823
2013-12-19 14:07Brad KingNote Added: 0034827
2013-12-20 01:18jschuellerNote Added: 0034833
2014-04-01 03:58jschuellerNote Added: 0035594
2014-04-01 03:58jschuellerStatusnew => closed
2014-04-01 03:58jschuellerResolutionopen => won't fix

Notes
(0034796)
jschueller   
2013-12-18 13:44   
Here are some more infos:
the isystem flag seem to come Compiler/GNU.cmake,
it must not be qt specific


The configure output:
-- The CXX compiler identification is GNU 4.8.2
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/i686-w64-mingw32/bin/qmake (found version "4.8.5")
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_INSTALL_LIBDIR
    INCLUDE_INSTALL_DIR
    LIB_INSTALL_DIR
    SHARE_INSTALL_DIR
    SYSCONF_INSTALL_DIR


-- Build files have been written to: ..../pkgtest/build




The toochain file:
SET(CMAKE_SYSTEM_NAME Windows)

# specify the cross compiler
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Make sure Qt can be detected by CMake
SET(QT_BINARY_DIR /usr/i686-w64-mingw32/bin /usr/bin)

# set the resource compiler (RHBZ #652435)
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)

# override boost library suffix which defaults to -mgw
SET(Boost_COMPILER -gcc47)

# These are needed for compiling lapack (RHBZ #753906)
SET(CMAKE_Fortran_COMPILER i686-w64-mingw32-gfortran)
SET(CMAKE_AR:FILEPATH i686-w64-mingw32-ar)
SET(CMAKE_RANLIB:FILEPATH i686-w64-mingw32-ranlib)
(0034814)
Stephen Kelly   
2013-12-18 18:56   
Doesn't seem to be related to what I work on.
(0034816)
Brad King   
2013-12-19 09:50   
The GNU.cmake entry is just a mapping that tells CMake what flag to use for system include paths with the GNU compiler. The -isystem flag is used because something in the Qt4 infrastructure tells CMake that the include path is a system include path.
(0034823)
Stephen Kelly   
2013-12-19 10:47   
I can point to commit 691ac05d4049619407b6ff0b89207c5c77e21ae0 but don't know anythnig about this bug report beyond that.
(0034827)
Brad King   
2013-12-19 14:07   
For reference, commit 691ac05d4049619407b6ff0b89207c5c77e21ae0 is:

 Qt4: Add SYSTEM option to include_directories
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=691ac05d [^]
(0034833)
jschueller   
2013-12-20 01:18   
Ok, if I set -DQT_INCLUDE_DIRS_NO_SYSTEM=ON, it works fine.

QT_INCLUDE_DIRS_NO_SYSTEM is not set anywhere:
$ grep -nr QT_INCLUDE_DIRS_NO_SYSTEM /usr/share/cmake-2.8/
/usr/share/cmake-2.8/Modules/UseQt4.cmake:28:if(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/UseQt4.cmake:30:else(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/UseQt4.cmake:32:endif(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/UseQt4.cmake:96: if(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/UseQt4.cmake:98: else(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/UseQt4.cmake:100: endif(QT_INCLUDE_DIRS_NO_SYSTEM)
/usr/share/cmake-2.8/Modules/FindQt4.cmake:74:# QT_INCLUDE_DIRS_NO_SYSTEM
(0035594)
jschueller   
2014-04-01 03:58   
SET(QT_INCLUDE_DIRS_NO_SYSTEM ON) fixed this