Understanding CMake Policy CMP0100: Processing Header Files with .hh Extension


Before CMake 3.17

  • Files with the .hh extension were ignored.
  • By default, AUTOMOC and AUTOUIC only processed header files ending with the .h extension.

After CMake 3.17 (with CMP0100 enabled)

  • AUTOMOC and AUTOUIC now also process header files ending with the .hh extension.

This policy provides more flexibility in how you name your header files while still being compatible with these tools.

  • New Behavior (With CMP0100)
    Process .hh files alongside .h files.
  • Default Behavior (Before CMP0100)
    Ignore .hh files.
  • Effect
    Enables AUTOMOC and AUTOUIC to process header files with the .hh extension.
  • Introduced In
    CMake 3.17
  • Policy Name
    CMP0100


Example 1: Enabling CMP0100

This example explicitly enables CMP0100 for a cleaner build without warnings.

cmake_policy(CMP0100 NEW)

# Rest of your CMakeLists.txt code
  • cmake_policy(CMP0100 NEW) sets the policy CMP0100 to the new behavior, ensuring AUTOMOC and AUTOUIC process .hh files.

Example 2: Handling the Warning (Without Enabling)

This example demonstrates how to silence the warning if you're not ready to enable CMP0100 yet or have specific reasons to keep the old behavior.

# Set the source file property to skip processing by AUTOMOC/AUTOUIC
set_property(SOURCE /path/to/your/file.hh PROPERTY SKIP_AUTOMOC ON)

# Rest of your CMakeLists.txt code
  • set_property(SOURCE /path/to/your/file.hh PROPERTY SKIP_AUTOMOC ON) sets the SKIP_AUTOMOC property for the specific header file file.hh. This tells CMake to exclude it from processing by AUTOMOC. You can use SKIP_AUTOUIC for similar exclusion with AUTOUIC.
  • If you have specific reasons to keep the old behavior (ignoring .hh files), use property exclusion (Example 2) to silence the warning for specific header files. However, consider updating your project to take advantage of the new behavior in the future.
  • If your project uses .hh header files and you're working with CMake 3.17 or later, enabling CMP0100 (Example 1) is recommended for better compatibility.


  1. Renaming Header Files
  • If you're not strongly tied to the .hh extension, the simplest solution might be to rename your header files to the standard .h extension. This ensures compatibility with both old and new CMake versions without needing policy changes.
  1. Excluding Specific Files (if needed)
  • If some of your .hh files shouldn't be processed by AUTOMOC or AUTOUIC even with CMP0100 enabled, you can still utilize file property exclusion as shown in the previous example. This allows for granular control over which files are processed by these tools.
  1. Alternative Header Generation Tools

Remember, the best approach depends on your project's requirements and coding style. Consider factors like:

  • Consistency and maintainability of your codebase
  • Specific functionality required from AUTOMOC or AUTOUIC
  • Compatibility needs (older vs. newer CMake versions)