c++qtcmakeautomocking

Handle files with the same name by automoc


There is the following source tree:

*-source
*----subsource
*--------Source1.hpp
*----Source1.hpp

Both files, ./Source1.hpp and ./subsource/Source1.hpp, must be handled by moc. When using automoc it puts output moc files to the same directory with the same name, since it is impossible it overwrites the file.

Qt - 5.2

CMake - 2.8.12

CMake files are rather big, but here is a brief example:

# Main CMakeLists.txt
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)


add_subdirectory("${CMAKE_SOURCE_DIR}/components/Com1" ./Com1)


# Com1 CMakeLists.txt in components/Com1

file(GLOB_RECURSE CPP_FILES source/*.cpp)
add_library(Com1 SHARED ${CPP_FILES})

Any solutions?


Solution

  • The tracker claims this is fixed in CMake 3.6:

    http://public.kitware.com/Bug/view.php?id=12873