MantisBT - CMake
View Issue Details
0013493CMakeCMakepublic2012-08-27 09:132012-10-24 17:28
Stephen Kelly 
Alex Neundorf 
normalminorhave not tried
closedfixed 
CMake 2.8.10 
CMake 2.8.10CMake 2.8.10 
0013493: CMake AUTOMOC does not read target properties when generating moc info file.
In the cmQtAutomoc file, the property INCLUDE_DIRECTORIES for example is read from the makefile, not from the target. It bypasses the logic in cmTarget::GetIncludeDirectories. The GetIncludeDirectories method should be used instead.

This becomes more relevant in Qt 5 because plugin building is based on moc generating code by reading a json file specified in a macro. (see Q_PLUGIN_METADATA in http://doc-snapshot.qt-project.org/5.0/plugins-howto.html [^])

The json file must be in one of the include directories. If include_directories is used, it currently works, but if set_property(TARGET ...) is used it does not work.

Similarly, COMPILE_DEFINITIONS should be taken from the target too.
No tags attached.
Issue History
2012-08-27 09:13Stephen KellyNew Issue
2012-08-27 09:13Stephen KellyStatusnew => assigned
2012-08-27 09:13Stephen KellyAssigned To => Alex Neundorf
2012-08-27 16:10Alex NeundorfNote Added: 0030781
2012-08-28 03:08Stephen KellyNote Added: 0030785
2012-08-28 16:20Alex NeundorfNote Added: 0030789
2012-08-29 05:18Stephen KellyNote Added: 0030793
2012-09-05 16:01Alex NeundorfNote Added: 0030929
2012-09-19 11:46Alex NeundorfNote Added: 0031064
2012-09-19 11:46Alex NeundorfStatusassigned => closed
2012-09-19 11:46Alex NeundorfResolutionopen => fixed
2012-09-19 11:46Alex NeundorfDescription Updatedbug_revision_view_page.php?rev_id=843#r843
2012-10-24 17:28David ColeFixed in Version => CMake 2.8.10
2012-10-24 17:28David ColeTarget Version => CMake 2.8.10

Notes
(0030781)
Alex Neundorf   
2012-08-27 16:10   
Like this ? http://cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/AutomocUseTargetProperties [^]
(0030785)
Stephen Kelly   
2012-08-28 03:08   
The target->GetProperty("INCLUDE_DIRECTORIES"); seems to work currently, but will not work when include_directories can contain generator expressions. The code in question runs at generate-time. Why do you not want to use target->GetIncludeDirectories() as all other generators do?

I tested the target->GetProperty("COMPILE_DEFINITIONS"); change and it seems to work, but I can't figure out how. COMPILE_DEFINITIONS does not 'chain', and I can't find any code that initializes the target property from the Makefile, as is done for INCLUDE_DIRECTORIES. How does that work?

The COMPILE_DEFINITIONS change has the same problem with regard to future generator expressions, but there is not really any better API for that yet as there is for GetIncludeDirectories (though there is cmLocalGenerator::AppendDefines which could be made static and would enforce uniqueness).

Additionally I notice that the COMPILE_DEFINITIONS_${CONFIG} variables are not handled with Automoc, as they are with other generators. It probably makes sense to fix this in the same branch to do more like what, eg, the Ninja generator does in cmNinjaTargetGenerator::ComputeDefines().
(0030789)
Alex Neundorf   
2012-08-28 16:20   
No problem, I can use GetIncludeDirectories(), it's just that when I looked at the (current) code, the only thing it does over the plain GetProperty("INCLUDE_DIRECTORIES") is to remove duplicates and turn it into a vector, which I have to turn back into a string then, so I thought it's easier and has the same effect as directly getting the property.
But if you think it's better, I can use GetIncludeDirectories().
(0030793)
Stephen Kelly   
2012-08-29 05:18   
Ok, cool. Any idea about how the target->GetProperty("COMPILE_DEFINITIONS"); seems to get the COMPILE_DEFINITIONS from the makefile too? Any response to the configuration specific COMPILE_DEFINITIONS?
(0030929)
Alex Neundorf   
2012-09-05 16:01   
The include dirs should now be handled correctly in the AutomocUseTargetProperties branch on stage.
I still need to have a look at the compile definitions.
(0031064)
Alex Neundorf   
2012-09-19 11:46   
Merged the AutomocUseTargetProperties branch into next.