1

I'm working on converting an existing project to CMake. I'd like to use CMake's built-in AUTOMOC feature, but since I can't use find_package(Qt4) (due to the custom location of the project's Qt4 binaries/libs/headers/etc.) it's not clear how to enable it. What's the magic sauce?

Artfunkel
  • 1,832
  • 17
  • 23

1 Answers1

1

Here's a portable makefile snippet that triggers automoc:

set(CMAKE_AUTOMOC TRUE)
set(QT_VERSION_MAJOR 4)

find_program(QT_MOC_EXECUTABLE qt_moc48 PATHS ${MY_BINARIES}) 
add_executable(Qt4::moc IMPORTED)
set_property(TARGET Qt4::moc PROPERTY IMPORTED_LOCATION ${QT_MOC_EXECUTABLE})
Artfunkel
  • 1,832
  • 17
  • 23