# VERIFY_PRIVATE_HEADER_SETS

Added in version 4.3.

Changed in version 4.4: `OBJC` and `OBJCXX` languages are now supported in addition to `C` and `CXX`.

Used to verify that all headers in a target's `PUBLIC` and `PRIVATE` header sets can be included on their own.

Changed in version 4.4: Previously, the verification target was only created when the target had at least one matching header. Now it is always created when the property is enabled.

When this property is set to true, and the target is an object library, static library, shared library, module library, interface library, or executable, an object library target named `<target_name>_verify_private_header_sets` is created. This verification target has one source file per header in the target's `PUBLIC` and `PRIVATE` header sets. Each source file only includes its associated header file. If the target has no matching header sets, a utility target is created instead so that the target name always exists for build system dependencies.

Properties affecting compilation are copied from the original target to the verification target so that the headers will be interpreted the same way by the compiler as when compiling the original target's sources. There are some caveats with this approach. It cannot replicate the same conditions if any of those properties or properties inherited through build requirements from transitive dependencies contain target-dependent generator expressions that do not specify the target for the expansion. Such expressions can expand to different contents depending on the target they are being used on.

The verification target has its `EXCLUDE_FROM_ALL` and `DISABLE_PRECOMPILE_HEADERS` properties set to true, and its `AUTOMOC`, `AUTORCC`, `AUTOUIC`, `UNITY_BUILD`, and `CXX_SCAN_FOR_MODULES` properties set to false.

If the header's `LANGUAGE` property is set, the value of that property is used to determine the language with which to compile the header file. The supported languages are `C`, `CXX`, `OBJC`, and `OBJCXX`. If the language is not one of those four, the header file is not compiled.

Otherwise, the language is inferred from the target's sources using the following precedence: `OBJCXX` takes priority over all others; if both `CXX` and `OBJC` sources are present, the header is compiled as `OBJCXX`; otherwise `CXX` takes precedence over `OBJC`, and `OBJC` takes precedence over `C`. If no matching sources are found, the same precedence is applied to the globally enabled languages. If no supported language is found, the header file is not compiled.

If the header's `SKIP_LINTING` property is set to true, the file is not compiled.

If `VERIFY_PRIVATE_HEADER_SETS` and `VERIFY_INTERFACE_HEADER_SETS` are both set to true, headers belonging to `PUBLIC` file sets will be verified twice, but with different conditions. The compiler flags used for private and interface contexts can be different, leading to the compiler interpreting the contents of the header differently.

A top-level target called `all_verify_private_header_sets` is created which depends on all private verification targets. Another target called `all_verify_header_sets` is also created which depends on `all_verify_private_header_sets`, and on `all_verify_interface_header_sets` if it exists (see `VERIFY_INTERFACE_HEADER_SETS`).

This property is initialized by the value of the `CMAKE_VERIFY_PRIVATE_HEADER_SETS` variable if it is set when a target is created.

If the project wishes to control which header sets are verified by this property, it can set `PRIVATE_HEADER_SETS_TO_VERIFY`.