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

Roger Leigh rleigh at codelibre.net
Sun Dec 14 14:29:38 EST 2014


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.
Unfortunately, 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.

- is this a known issue?
- 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 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


More information about the CMake mailing list