CPM.cmake
CPM.cmake copied to clipboard
CPM_INDENT is not inserted everywhere and no CPM_DESINDENT
Hello,
Thx for you nice tool it's wonderful.
I noticed that CPM_INDENT is not used everywhere in the code? This is expected ?
I would like to add an CPM_DESINDENT or other name to be able to use CPM_INDENT to use colorization. For now I can do it but I can't desactivate the color.
It wouyld be then possible to do :
set(CPM_INDENT MyColor)
set(CPM_DESINDENT White)
Would you accept a PR to add this variable CPM_DESINDENT or a better name ?
Hey thanks for the feedback, happy you like it!
I noticed that CPM_INDENT is not used everywhere in the code? This is expected ?
Hm I think there are some places where the indent wouldn't make sense as they are not scoped, e.g. fatal errors. For other purposes this may be an oversight.
I would like to add an CPM_DESINDENT or other name to be able to use CPM_INDENT to use colorization. For now I can do it but I can't desactivate the color.
I'm not sure if that would already be too far off from its original meaning. Maybe it would be better to introduce two new variables like CPM_LEFT_LOG, CPM_RIGHT_LOG? Probably it would also make sense to add a function for logging, for more consistency and easier customisation.
Yes I agree the name is not very nice. And the ones proposed are much better..
Concerning the indent on fatal errors it's true indentation are not useful but I used CPM_INDENT as [CPM].
Addind the values you propose looks great. For a logger I wrote something like this : https://github.com/flagarde/CMakeCM/blob/main/modules/Missives.cmake but it's maybe too much code just for logging some message in cpm
Would you allow a PR with CPM_LEFT_LOG CPM_RIGHT_LOG ?
Sure, though if its a lot of extra code, I think I'd prefer a small helper function for logging. But I'd be happy to take a look at the PR!
Well it depends a lot of what you expect from a logger.
- Colorization : Possible but need to hack a bit as CMake doesn't provide any hint to know if the terminal or IDE accept ANSI color escape sequences. I raised an issue https://gitlab.kitware.com/cmake/cmake/-/issues/22954 for this.
- Add level : be able to register new levels based on the default ones.
This is what can be done with around ~200 lines of code (would need more to check TERM env for colorization)
missive_mode(NAME "MY_ERROR" PARENT_MODE FATAL_ERROR STYLE "Blue" APPEND_BEGIN "#### " APPEND_END " !!!!!!!!" APPEND_STYLE_BEGIN "Green" APPEND_STYLE_END "BoldYellow")
missive_mode(NAME "PYTHON" STYLE "Green" APPEND_BEGIN "[Python]:" APPEND_END "!!" APPEND_STYLE_BEGIN "BackGreen" APPEND_STYLE_END "Yellow" )
missive_mode(NAME "SEND_ERROR" STYLE "BoldRed")
missive(SEND_ERROR "ERROR!!!")
message(STATUS "")
missive(PYTHON "I'm a python message")
message(STATUS "")
missive(MY_ERROR "OUPS")
After CMAke 3.21 :

Before:
