Proposal: Introduce `being_check`/`end_check`
The problem
Nowadays to report tests executed the STATUS
type messages are widely used.
That way is error-prone and violates the don't-repeat-yourself (DRY) principle.
The CMake-time tests typically look like this:
message(STATUS "Looking for `libfoo.h`")
...
if(BLAH_BLAH)
message(STATUS "Looking for `libfoo.h` - found")
else()
message(STATUS "Looking for `libfoo.h` - not found")
endif()
CMake has quite a lot of similar code. It duplicates the intro message 3 times. The checking result messages also vary a lot:
-
Success
/Failed
-
found
/not found
-
True
/False
-
done
/failed
-
works
/broken
-
yes
/no
Also, using capitalized words looks a bit inconsistent to me.
The Proposal
In !3689 (merged) @purpleKarrot proposed to introduce the dedicated commands for this:
begin_check("Looking for `libfoo.h`")
...
end_check(FOO_FOUND)
I see the following topics to discuss:
- Is it worth to add dedicated commands? Personally, I think it is...
- Need some "better" names to follow CMake's tradition to have pairs
xxx()
/endxxx()
- Checking results are not only
found
/not-found
-- how to give a user ability to print whatever he wants? - What is the log-level of the message printed by
begin_check
? Is itSTATUS
? IMO, having a dedicated log-level could help to future extensions (like one described in #19438) to better understand semantic of the message printed. - smth else?