GCC coverage flag breaks CMAKE_EXECUTABLE_FORMAT with CMP0126 set to NEW (CMake 3.21.0)
The following project:
cmake_minimum_required(VERSION 3.21)
#cmake_policy(SET CMP0126 OLD)
project(Foo C)
message("CMAKE_EXECUTABLE_FORMAT: [${CMAKE_EXECUTABLE_FORMAT}]")
Incorrectly reports:
CMAKE_EXECUTABLE_FORMAT: [Unknown]
Rather than the expected:
CMAKE_EXECUTABLE_FORMAT: [ELF]
When configuring on Linux with GCC, CMP0126 set to NEW and CMAKE_C_FLAGS set to "--coverage" e.g.:
cmake -DCMAKE_C_FLAGS="--coverage" ...
In my actual project this later leads to failures like:
The install of the Foo target requires changing an RPATH from
the build tree, but this is not supported with the Ninja generator unless
on an ELF-based or XCOFF-based platform. The
CMAKE_BUILD_WITH_INSTALL_RPATH variable may be set to avoid this relinking
step.