[Interest] Qt automoc (CMAKE_AUTOMOC) failure with name clashes

Roger Leigh rleigh at codelibre.net
Sun Dec 14 21:58:58 CET 2014


I brought this up on the cmake list, since I think this is likely an
issue with the cmake automoc implementation, but also posting here
since it's primarily an issue when using Qt.

I have a source directory layout like this:
├── gl
│   ├── Axis2D.h
│   ├── Grid2D.h
│   ├── Image2D.h
│   └── v20
│       ├── Axis2D.h
│       ├── Grid2D.h
│       └── Image2D.h
├── GLContainer.h
├── glsl
│   └── v110
│       ├── GLFlatShader2D.h
│       ├── GLImageShader2D.h
│       └── GLLineShader2D.h
├── GLUtil.h
├── GLView2D.h
├── GLWindow.h
└── TexelProperties.h

And use this cmake configuration:

  set(CMAKE_AUTOMOC ON)
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  set(QTWIDGETS_GL_HEADERS
      gl/Axis2D.h
      gl/Grid2D.h
      gl/Image2D.h)
  set(QTWIDGETS_GL_V20_HEADERS
      gl/v20/Axis2D.h
      gl/v20/Grid2D.h
      gl/v20/Image2D.h)

As you can see, the names are duplicated in the two subdirectories.
I plan to have even more dupliated names as I add support for
multiple gl/glsl versions.
Unfortunately, cmake automoc generates this:

/* This file is autogenerated, do not edit*/
#include "moc_GLContainer.cpp"
#include "moc_GLView2D.cpp"
#include "moc_GLWindow.cpp"
#include "moc_Axis2D.cpp"
#include "moc_Grid2D.cpp"
#include "moc_Image2D.cpp"
#include "moc_Axis2D.cpp"
#include "moc_Grid2D.cpp"
#include "moc_Image2D.cpp"
#include "moc_GLFlatShader2D.cpp"
#include "moc_GLImageShader2D.cpp"
#include "moc_GLLineShader2D.cpp"

Compilation inevitably fails due to it including the generated source
files twice.  It's discarded the path information and overwritten the
generated sources where the names clash.

- I've seen some old posts to this list and in other places which show
  this has been an issue historically, and the suggestion has been to
  rename the source/header files.  However, that's not always possible
  or acceptable.  In this case, it's definitely not.  There's no problem
  with the sources/headers themselves, which are correct, just with moc.
- is there any way to get automoc support to add the full pathname to
  the generated sources e.g. moc_gl_Axis2D.cpp and moc_gl_v20_Axis2D.cpp.
- any workarounds with cmake known for this issue?


Many thanks,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800



More information about the Interest mailing list