CMake Coding Style - Razor-qt/razor-qt GitHub Wiki

This wiki page describes the recommended coding style for CMake files.

Indentation

Use 4 spaces for indenting and indent ALL blocks:

  • if/else/endif
  • foreach/endforeach
  • while/endwhile
  • macro/endmacro
  • function/endfunction

Upper/lower case

CMake is case-sensitive only for arguments or variables names. The commands are case-insensitive but we prefer the lowercase style.

Please, don't use unnecessary spaces:

wrong:

if ( HAS_LIB_X )
    add_subdirectory( dir )
endif ( HAS_LIB_X )

correct:

if (HAS_LIB_X)
    add_subdirectory(dir)
endif (HAS_LIB_X)