Verify header sets behavior for interface library with no LANGUAGE set is unexpected
This has been split out of !7507 (comment 1221124).
The following is a minimal example of a typical header-only library, as we might commonly find in the wild. I've added support for the new header verification feature being introduced in CMake 3.24, but there's a problem:
cmake_minimum_required(VERSION 3.24)
project(verify_header_sets)
add_library(MyHeaderOnly INTERFACE)
target_sources(MyHeaderOnly INTERFACE FILE_SET HEADERS FILES blah.h)
set_target_properties(MyHeaderOnly PROPERTIES
VERIFY_INTERFACE_HEADER_SETS TRUE
)
What's missing is that there's nothing set on the target or the header file to indicate what language to compile the verification file as. According to the current docs, the behavior in this case is to not verify the header at all (this was discussed in the original issue. The current behavior relies on either there being a language set on the target, which you normally won't have for an interface library, or set on the individual headers, which most projects are not typically going to have or want to do.
I think we can improve this situation. In cases like these, rather than just giving up, we should look at what languages are enabled globally. If CXX is enabled, use that, otherwise if C is enabled, use that. Only if neither of those languages are enabled should we then give up. I think this would better reflect the intuitive expectation of most users.