Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with precompiled header and generic Qt includes on OSX #118

Open
kapecp opened this issue May 21, 2017 · 2 comments
Open

Problem with precompiled header and generic Qt includes on OSX #118

kapecp opened this issue May 21, 2017 · 2 comments

Comments

@kapecp
Copy link

kapecp commented May 21, 2017

Hi

First thank you for this great tool!

After upgrading my large project from Qt4 to Qt5 the following problem occured.

related issue: #69

environment:

  • OSX 10.11.6
  • CMake 3.8.0 (installed via Homebrew)
  • Cotire 1.7.9 (master HEAD, commit 3d63330)
  • Qt 5.8.0_2 (installed via Homebrew)

This is a minimal example that re-produces the error:
(using COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES=1)

CMakeLists.txt:

project( QtGUI_problem CXX C )
cmake_minimum_required( VERSION 3.6 )
set( CMAKE_MODULE_PATH
	"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cotire/CMake"
	${CMAKE_MODULE_PATH} )
set(CMAKE_CXX_STANDARD 11)
include( cotire )
if( COMMAND cotire )
	set( COTIRE_VERBOSE TRUE )
	set( COTIRE_DEBUG TRUE )
endif()
find_package( Qt5Gui )
add_executable( app main.cpp)
target_link_libraries(app Qt5::Gui)
if( COMMAND cotire )
	set_target_properties( app PROPERTIES COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY")
	cotire( app CONFIGURATIONS Debug)
endif()

main.cpp:

#include <QtGui>			// this causes the wrong path
// #include <QtGui/QIcon>	// this works
// #include <QIcon> 		// this works
int main( int argc, char* argv[] )
{
}

When building via make all
the precomiled header in _build/cotire/app_CXX_prefix.cxx contains:

#pragma clang system_header
#ifdef __cplusplus
#include "/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/QtGui"
#endif

which results in the following compile error:
_build/cotire/app_CXX_prefix.cxx:5: /usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/QtGui:1:1: error: source file is not valid UTF-8 <CF><FA><ED><FE><U+0007>
because the /usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/QtGui
is actually a dynamically linked shared library, but
the header file #include <QtGui> is actually here
/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers/QtGui

so the generated path is wrong (missing "Headers"), however using any header like
#include <QtGui/QIcon> or #include <QIcon>
(QIcon is in /usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers/QIcon)
will produce a correct build/cotire/app_CXX_prefix.cxx like, e.g.

#pragma clang system_header
#ifdef __cplusplus
#include "/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers/QIcon"
#endif  

so it seems to be only caused by including "generic" headers of Qt modules

more details:
output of cmake -DCOTIRE_DEBUG=TRUE .

cotire 1.7.9 loaded.
Target app compile flags: -g;-fPIC
Filter arch unmatched: -g;-fPIC
C source file extensions: c;m
C ignore extensions: h;H;o;O;obj;OBJ;def;DEF;rc;RC
C exclude extensions: m;mm
Target app compile flags: -g;-fPIC;-std=gnu++11
Filter arch unmatched: -g;-fPIC;-std=gnu++11
CXX source file extensions: C;M;c++;cc;cpp;cxx;mm;CPP
CXX ignore extensions: inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC
CXX exclude extensions: m;mm
Filtered app CXX sources: main.cpp
CXX target app cotired.
CXX source file extensions: C;M;c++;cc;cpp;cxx;mm;CPP
CXX ignore extensions: inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC
CXX exclude extensions: m;mm
Filtered app CXX sources: main.cpp
Target app compile flags: -g;-fPIC;-std=gnu++11
Filter I unmatched: -g;-fPIC;-std=gnu++11
Filter isystem unmatched: -g;-fPIC;-std=gnu++11
Target app include dirs: /usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework;/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers;/System/Library/Frameworks/OpenGL.framework/Headers;/usr/local/Cellar/qt/5.8.0_2/lib/QtCore.framework;/usr/local/Cellar/qt/5.8.0_2/lib/QtCore.framework/Headers;/usr/local/Cellar/qt/5.8.0_2/.//mkspecs/macx-clang
Target app compile flags: -g;-fPIC;-std=gnu++11
Filter D unmatched: -g;-fPIC;-std=gnu++11
Target app compile definitions: QT_GUI_LIB;QT_CORE_LIB;$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>
Target app compile flags: -g;-fPIC;-std=gnu++11
Filter D|I|isystem unmatched: -g;-fPIC;-std=gnu++11
Target app compiler flags: -g;-fPIC;-std=gnu++11
# cotire.cmake 1.7.9 generated file
# /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_cotire.cmake
set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "inc;inl;ipp")
set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "")
set (COTIRE_CLEAN_ALL_TARGET_NAME "clean_cotire")
set (COTIRE_CLEAN_TARGET_SUFFIX "_clean_cotire")
set (COTIRE_CMAKE_MODULE_FILE "/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/cmake/cotire/CMake/cotire.cmake")
set (COTIRE_CMAKE_MODULE_VERSION "1.7.9")
set (COTIRE_DEBUG "TRUE")
set (COTIRE_DEBUG "TRUE")
set (COTIRE_INTDIR "cotire")
set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "0")
set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "1")
set (COTIRE_PCH_ALL_TARGET_NAME "all_pch")
set (COTIRE_PCH_TARGET_SUFFIX "_pch")
set (COTIRE_PREFIX_HEADER_FILENAME_SUFFIX "_prefix")
set (COTIRE_TARGETS_FOLDER "cotire")
set (COTIRE_TARGET_COMPILE_DEFINITIONS_DEBUG "QT_GUI_LIB;QT_CORE_LIB;$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>")
set (COTIRE_TARGET_COMPILE_FLAGS_DEBUG "-g;-fPIC;-std=gnu++11")
set (COTIRE_TARGET_CONFIGURATION_TYPES "Debug")
set (COTIRE_TARGET_CXX_COMPILER_LAUNCHER "COTIRE_TARGET_CXX_COMPILER_LAUNCHER-NOTFOUND")
set (COTIRE_TARGET_IGNORE_PATH "/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem")
set (COTIRE_TARGET_INCLUDE_DIRECTORIES_DEBUG "/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework;/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers;/System/Library/Frameworks/OpenGL.framework/Headers;/usr/local/Cellar/qt/5.8.0_2/lib/QtCore.framework;/usr/local/Cellar/qt/5.8.0_2/lib/QtCore.framework/Headers;/usr/local/Cellar/qt/5.8.0_2/.//mkspecs/macx-clang")
set (COTIRE_TARGET_INCLUDE_PRIORITY_PATH "")
set (COTIRE_TARGET_LANGUAGE "CXX")
set (COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES "")
set (COTIRE_TARGET_POST_UNDEFS "")
set (COTIRE_TARGET_PRE_UNDEFS "")
set (COTIRE_TARGET_SOURCES "main.cpp")
set (COTIRE_UNITY_BUILD_ALL_TARGET_NAME "all_unity")
set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity")
set (COTIRE_UNITY_OUTPUT_DIRECTORY "")
set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm")
set (COTIRE_UNITY_SOURCE_FILENAME_SUFFIX "_unity")
set (CMAKE_GENERATOR "Unix Makefiles")
set (CMAKE_BUILD_TYPE "Debug")
set (CMAKE_CXX_COMPILER_ID "Clang")
set (CMAKE_CXX_COMPILER_VERSION "8.0.0.8000042")
set (CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++")
set (CMAKE_CXX_COMPILER_ARG1 "")
set (CMAKE_INCLUDE_FLAG_CXX "-I")
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
set (CMAKE_CXX_FRAMEWORK_SEARCH_FLAG "-F")
set (CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
set (CMAKE_CXX_SOURCE_FILE_EXTENSIONS "C;M;c++;cc;cpp;cxx;mm;CPP")

/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_cotire.cmake unchanged
app unity source max includes: 0
unity files: /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx
add_custom_command: OUTPUT /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx COMMAND /Applications/CMake.app/Contents/bin/cmake;--warn-uninitialized;-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>;-DCOTIRE_VERBOSE:BOOL=ON;-P;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/cmake/cotire/CMake/cotire.cmake;unity;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>_cotire.cmake;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx DEPENDS /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>_cotire.cmake
add_custom_command: OUTPUT /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.cxx COMMAND /Applications/CMake.app/Contents/bin/cmake;--warn-uninitialized;-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>;-DCOTIRE_VERBOSE:BOOL=ON;-P;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/cmake/cotire/CMake/cotire.cmake;prefix;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>_cotire.cmake;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.cxx;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx DEPENDS /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
add_custom_command: OUTPUT /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx COMMAND /Applications/CMake.app/Contents/bin/cmake;--warn-uninitialized;-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>;-DCOTIRE_VERBOSE:BOOL=ON;-P;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/cmake/cotire/CMake/cotire.cmake;combine;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>_cotire.cmake;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.cxx DEPENDS /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.cxx
Target app compile flags: -g;-fPIC;-std=gnu++11
Filter arch unmatched: -g;-fPIC;-std=gnu++11
add_custom_command: OUTPUT /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx.pch /Applications/CMake.app/Contents/bin/cmake;--warn-uninitialized;-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>;-DCOTIRE_VERBOSE:BOOL=ON;-P;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/cmake/cotire/CMake/cotire.cmake;precompile;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/app_CXX_$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>_cotire.cmake;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx;/Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx.pch;main.cpp DEPENDS /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ IMPLICIT_DEPENDS CXX /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_prefix.hxx
CXX source file extensions: C;M;c++;cc;cpp;cxx;mm;CPP
CXX ignore extensions: inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC
CXX exclude extensions: m;mm
Filtered app CXX sources: main.cpp
add target EXECUTABLE app_unity  EXCLUDE_FROM_ALL /Users/kapec/Desktop/Dev/Tmp/QtGUI-problem/_build/cotire/app_CXX_unity.cxx
unity target app_unity link strategy: COPY_UNITY
unity target app_unity link libraries: Qt5::Gui
unity target app_unity interface link libraries: Qt5::Gui
Configuring done

possible source of the problem:
COTIRE_TARGET_INCLUDE_DIRECTORIES_DEBUG contains
/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework;/usr/local/Cellar/qt/5.8.0_2/lib/QtGui.framework/Headers;
(as the result of /usr/local/Cellar/qt/5.8.0_2/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake)

Unity build works OK.
My current workaround: do not use #include <QtGui>

@macdew
Copy link

macdew commented Sep 17, 2018

This may have been fixed with Cotire 1.8.0 - at least I'm not getting this particular problem anymore (I was with 1.7.10). However, I have filed a separate issue #166 against 1.8.0.

@macdew
Copy link

macdew commented Sep 21, 2018

I was wrong about thinking it was fixed with Cotire 1.8.0. I'm also still seeing this problem. Oddly enough, some includes are ok, but there's still the root file in a Qt framework being pulled in (in my case it's QtWidgets).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants