cotire
cotire copied to clipboard
error using qt 5, cmake 3.2.1 automoc with unity build
Hi, first of all thanks for this great cmake module. I use it for precompiled header generation a longer time now. Using qt 5.5.0 git, cmake 3.2.1 , corire 1.7.0 Now i started to use unity build and ran into this error: linking fails because of duplicate symbols. metatypes symbols being multiple defined . this comes from lining src/MyProgram/CMakeFiles/MyProgram_unity.dir/MyProgram_automoc.cpp.obj and src/MyProgram/CMakeFiles/MyProgram_unity.dir/MyProgram_unity_automoc.cpp.obj
I fixed that by removing lines 2745 and 2746: #list (APPEND _unityTargetSources "${_target}_automoc.cpp") #set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE)
But i think these lines serve some purpose. maybe it is only needed if COTIRE_UNITY_LINK_LIBRARIES_INIT is NOT COPY_UNITY?
Regards, Rodion
Please give the recently released version 1.7.1 a try. It contains a fix for the problem.
Possibly related to this - I am receiving the following error:
CMake Error at cmake/cotire.cmake:2756 (add_dependencies): The dependency target "QtApp_automoc" of target "QtApp_unity" does not exist. Call Stack (most recent call first): cmake/cotire.cmake:2932 (cotire_setup_unity_build_target) cmake/cotire.cmake:3071 (cotire_target)
Environment:
- Qt 5.5.0
- CMake 3.2.2
- Cotire 1.7.2
Any ideas on the cause of this?
@nickdademo Do you use automoc in your project?
I sure do. Via: set(CMAKE_AUTOMOC ON)
Can you please check which of the following properties are set on your target before invoking cotire:
get_target_property(_targetAutoMoc ${_target} AUTOMOC)
get_target_property(_targetAutoUic ${_target} AUTOUIC)
get_target_property(_targetAutoRcc ${_target} AUTORCC)
As I know AUTOMOC doesn't generate targetname_automoc target. Now AUTOMOC creates targetname_automoc.cpp file and adds it to solution.
Without _automoc target impossible use add_dependencies(${_unityTargetName} ${_target}_automoc)
If set target property AUTOGEN_TARGET_DEPENDS to ON then AUTOMOC creates new targetname_automoc target. But it's bad decision because AUTOGEN_TARGET_DEPENDS isn't global property.
Out of AUTOMOC, AUTOUIC and AUTORCC, only AUTOMOC is set.
I have tried to reproduce the problem, but in all my tests the _automoc
target exists, if one of the properties AUTO*
properties is set. Can you provide a small example that reproduces the problem?
Still getting this error after giving Cotire another go:
-- Configuring done
CMake Error at cmake/cotire.cmake:2938 (add_dependencies):
The dependency target "QtApp_automoc" of target "QtApp_unity" does not exist.
Call Stack (most recent call first):
cmake/cotire.cmake:3132 (cotire_setup_unity_build_target)
cmake/cotire.cmake:3294 (cotire_target)
sources/application/CMakeLists.txt:124 (cotire)
Environment: Qt 5.5.1 CMake 3.4.0 Cotire 1.7.8
I'll try and prepare a small example which reproduces the problem.
An example that reproduces the problem would be really helpful.
For some reason I'm having the exact same problem, but only on Windows with CMake 3.5 and the NMake generator. It works on mostly every other configuration.
Okay, so with a bit of investigation, it seems that the culprit is the Qt version...
On a ubuntu 16.04 docker machine, it does not work with the default Qt packages which are at 5.5 (I tried cmake 3.5 and 3.6, with make and ninja generator), but it works with the Qt 5.7 ppa (did not try Qt 5.6).
Thanks for the info! Do you have any ideas on what specifically in Qt 5.5 is making it fail?
sadly, no :( maybe this version does not set properly some variables in its Qt5Config.cmake or something like this...
Also having this issue.
CMake 3.8.0-rc1 Ninja Generator MSVC 14.0 Compiler CMAKE_AUTOMOC enabled Latest cotire.cmake from tip of master (2bb9cb6e8317ec42a7efbd0067eca9cbf728e03a)
Also getting it again with CMake 3.8.0-rc2, Qt 5.8, Makefile generator, under linux
@jcelerier, Does PR #112 work for you?
Eh, nevermind. missed the "under linux" part.
@nocnokneo it was another problem referenced in #114
The same problem Cannot open source file: QtClientGu_automoc.cpp OR QtClientGui\QtClientGui_autogen\moc_compilation.cpp Environment: cotire 1.7.10 CMake 3.7.2-win64 | 3.8.0-rc2-win64 | 3.10.1-win64 QT 5.9.1 Visual Studio 2017