View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012873CMakeCMakepublic2012-01-12 23:092016-06-10 14:21
Reporterjoseph2002 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformAllOSAllOS VersionAll
Product VersionCMake 2.8.7 
Target VersionCMake 3.6Fixed in VersionCMake 3.6 
Summary0012873: AUTOMOC produces same output moc file if target has two source files resides in different sub-directory
Descriptionconsider following directory structure:

src
src/CMakeLists.txt
src/sub1
src/sub1/test.h
src/sub1/test.cpp
src/sub2
src/sub2/test.h
src/sub2/test.cpp

src/CMakeLists.txt:
ADD_LIBRARY( testsrc sub1/test.cpp sub2/test.cpp )

Then AUTOMOC will produce the same moc_test.cpp in the binary folder of src:
${BINARY_DIR}/src/moc_test.cpp
${BINARY_DIR}/src/testsrc_automoc.cpp Which contains two lines of #include "moc_test.cpp"

This is not desired. CMake should keep directory structure when automocing, and produces:
${BINARY_DIR}/src/sub1/moc_test.cpp
${BINARY_DIR}/src/sub2/moc_test.cpp

TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0029992)
David Cole (manager)
2012-07-09 07:13

Unset target version field; too late for a fix to go into 2.8.9; deferred until a future version.
(0038539)
Kwabena W. Agyeman (reporter)
2015-04-17 23:11

This is still broken. It needs to be fixed...
(0039158)
Jan Steinke (reporter)
2015-07-20 05:11

I encountered the same behavior.
I agree with the author that it limits the power of cmake quite a lot. The only workaround is renaming the files manually so there are no two filenames the same. That, however, might take too much time depending on the size of the project. I spend several hours just renaming files and fixing imports.
(0040495)
Brad King (manager)
2016-02-16 10:50

Patch proposed in mailing list thread:

 [PATCH] Proposal of fix for issue 0012873 (AUTOMOC produces same output moc file if target has two source files resides in different sub-directory)
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15785 [^]
(0040506)
Brad King (manager)
2016-02-18 10:43

This has been fixed by the patch linked in 0012873:0040495:

 Automoc: Fix support of files with the same name
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9beb2744 [^]
(0040512)
Stephen Kelly (developer)
2016-02-19 05:33

I don't think that patch is correct. It should be possible to #include "moc_foo.cpp" in foo.cpp https://cmake.org/cmake/help/v3.0/prop_tgt/AUTOMOC.html [^]

I think the correct solution is to generate the moc files in different (per target) directories, and add those directories to the target INCLUDE_DIRECTORIES. See also

 QtAutogen: Put generated qrc files in a target-specific dir.
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33774ca2 [^]
(0040513)
Brad King (manager)
2016-02-19 09:01

Re 0012873:0040512: Good point, thanks. It looks like that documented behavior is not covered by the test suite though. That should be addressed as part of work on this issue too. I've reverted the change for now:

 Revert "Automoc: Fix support of files with the same name ..."
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=091b649e [^]
(0040845)
Brad King (manager)
2016-04-12 13:47

Re 0012873:0040513, 0012873:0040512: Additional discussion on mailing list:

http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/16229 [^]
(0040922)
Brad King (manager)
2016-04-22 09:02

Discussion in the thread linked in 0012873:0040845 resulted in this fix:

 Autogen: Generate not included moc files in subdirectories
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=488ea8c7 [^]
(0041185)
Kitware Robot (administrator)
2016-06-10 14:21

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2012-01-12 23:09 joseph2002 New Issue
2012-01-13 09:28 Brad King Assigned To => Alex Neundorf
2012-01-13 09:28 Brad King Status new => assigned
2012-01-18 14:37 Alex Neundorf Priority normal => high
2012-01-18 14:37 Alex Neundorf Target Version => CMake 2.8.8
2012-04-19 08:47 David Cole Target Version CMake 2.8.8 => CMake 2.8.9
2012-07-09 07:13 David Cole Note Added: 0029992
2012-07-09 07:18 David Cole Target Version CMake 2.8.9 =>
2012-08-13 14:26 Alex Neundorf Priority high => normal
2012-08-13 14:26 Alex Neundorf Status assigned => backlog
2015-04-17 23:11 Kwabena W. Agyeman Note Added: 0038539
2015-07-20 05:11 Jan Steinke Note Added: 0039158
2016-02-16 10:50 Brad King Note Added: 0040495
2016-02-18 10:43 Brad King Note Added: 0040506
2016-02-18 10:43 Brad King Status backlog => resolved
2016-02-18 10:43 Brad King Resolution open => fixed
2016-02-18 10:43 Brad King Fixed in Version => CMake 3.6
2016-02-18 10:43 Brad King Target Version => CMake 3.6
2016-02-19 05:33 Stephen Kelly Note Added: 0040512
2016-02-19 09:01 Brad King Note Added: 0040513
2016-02-19 09:01 Brad King Assigned To Alex Neundorf =>
2016-02-19 09:01 Brad King Status resolved => acknowledged
2016-02-19 09:01 Brad King Resolution fixed => open
2016-02-19 09:01 Brad King Fixed in Version CMake 3.6 =>
2016-02-19 09:01 Brad King Target Version CMake 3.6 =>
2016-04-12 13:47 Brad King Note Added: 0040845
2016-04-22 09:02 Brad King Note Added: 0040922
2016-04-22 09:02 Brad King Status acknowledged => resolved
2016-04-22 09:02 Brad King Resolution open => fixed
2016-04-22 09:02 Brad King Fixed in Version => CMake 3.6
2016-04-22 09:02 Brad King Target Version => CMake 3.6
2016-06-10 14:21 Kitware Robot Note Added: 0041185
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team