cotire icon indicating copy to clipboard operation
cotire copied to clipboard

error using qt 5, cmake 3.2.1 automoc with unity build

Open ghost opened this issue 9 years ago • 20 comments

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

ghost avatar Apr 01 '15 14:04 ghost

Please give the recently released version 1.7.1 a try. It contains a fix for the problem.

sakra avatar Apr 06 '15 20:04 sakra

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 avatar Jun 09 '15 21:06 nickdademo

@nickdademo Do you use automoc in your project?

sakra avatar Jun 10 '15 14:06 sakra

I sure do. Via: set(CMAKE_AUTOMOC ON)

nickdademo avatar Jun 10 '15 15:06 nickdademo

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)

sakra avatar Jun 29 '15 19:06 sakra

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.

oYASo avatar Jul 01 '15 12:07 oYASo

Out of AUTOMOC, AUTOUIC and AUTORCC, only AUTOMOC is set.

nickdademo avatar Jul 08 '15 21:07 nickdademo

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?

sakra avatar Jul 09 '15 05:07 sakra

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.

nickdademo avatar Apr 25 '16 08:04 nickdademo

An example that reproduces the problem would be really helpful.

sakra avatar Apr 25 '16 20:04 sakra

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.

jcelerier avatar Jun 29 '16 09:06 jcelerier

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).

jcelerier avatar Sep 20 '16 14:09 jcelerier

Thanks for the info! Do you have any ideas on what specifically in Qt 5.5 is making it fail?

nickdademo avatar Sep 20 '16 15:09 nickdademo

sadly, no :( maybe this version does not set properly some variables in its Qt5Config.cmake or something like this...

jcelerier avatar Sep 20 '16 15:09 jcelerier

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)

nocnokneo avatar Feb 10 '17 05:02 nocnokneo

Also getting it again with CMake 3.8.0-rc2, Qt 5.8, Makefile generator, under linux

jcelerier avatar Mar 06 '17 17:03 jcelerier

@jcelerier, Does PR #112 work for you?

nocnokneo avatar Mar 06 '17 17:03 nocnokneo

Eh, nevermind. missed the "under linux" part.

nocnokneo avatar Mar 06 '17 17:03 nocnokneo

@nocnokneo it was another problem referenced in #114

jcelerier avatar Mar 06 '17 19:03 jcelerier

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

Ktylx avatar Dec 27 '17 15:12 Ktylx