[cmake-developers] Preferred case for macro names?
Eric Noulard
eric.noulard at gmail.com
Tue Nov 13 05:36:24 EST 2018
Le mar. 13 nov. 2018 à 10:41, Marc CHEVRIER <marc.chevrier at gmail.com> a
écrit :
> I agree as well that trying to distinguish macros from functions is not a
> good idea because functions can act in the same way as macros (i.e.
> changing calling environment) but with a better control over environment
> changes (changes are done explicitly by using 'set(... PARENT_SCOPE)').
>
> so also +1 for lower case for every function, macro or builtin. And good
> point to standardize macro or function OPTION to UPPERCASE.
>
> Now, for variables, the problem is a bit different because they are case
> sensitive: 'set(my_var ...)' and 'set (MY_VAR ...)' will create two
> different variables.
>
Yes damn right.
> My personal tendency is to use lower case for local variables and upper
> case for global variables. May be we can normalize variables to upper case
> regarding global variables used by CMake itself (which is globally the
> current rule).
>
Having a convention for local is nice and I tend to prefix with _ (single
or double) variables that should be local.
lowercasing locals is fine too, however I think that enforcing casing on
"user-defined" variable may not be desirable, concerning CMAKE_ CTEST_ and
CPACK_
I guess they already are all UPPERCASE so we may stick with this as a
convention?
A small quote to the cmake-format (
https://github.com/cheshirekow/cmake_format) tool which is trying to
beautify CMakeLists.txt, I'm not using it on complex projects
because it still has some issues but I find it otherwise useful.
--
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20181113/83300c8e/attachment.html>
More information about the cmake-developers
mailing list