Search code examples
cmakeautomoc

How to switch off CMake automoc for subdirectories?


I have directory aaa and aaa/bb. I want CMake to create the moc_compilation.o file only for aaa/*.cxx files, but it scans recursively aaa/bb/*.cxx files also. How can I disable the recursive scan for automoc?


Solution

  • You can use the SKIP_AUTOMOC source file property to skip automoc processing for one file, or an entire group of files. This works for header files as well:

    file(GLOB MY_EXCLUDED_SOURCES aaa/bb/*.cxx)
    set_property(SOURCE ${MY_EXCLUDED_SOURCES} PROPERTY SKIP_AUTOMOC ON)