CMakeLists codingΒΆ
- Rule 1 : Function name
Standard CMake functions and macros should be written in lower case. Each word is generally separated by an underscore (this is a rule of CMake anyway).
add_subdirectory("library/") include_directories(SYSTEM "/usr/local")
- Rule 2 : Macro name
Custom macros should be written in camel case.
fwLoadProperties() fwLink("boost")
- Rule 3 : Variable name
Variables should be written in upper case letters separated if needed by underscores.
set(VARIABLE_NAME "")
- Recommendation 1 : Expression in block ending
In the past, CMake enforced to specify the label or expression in block ending, for instance :
function(name arg1 arg2) ... if(expr1) ... else(expr1) ... endif(expr1) ... endfunction(name)
This is no longer needed in latest CMake versions, and we recommend to use this possibility for the sake of simplicity.
function(name arg1 arg2) ... if(expr1) ... else() ... endif() ... endfunction()