Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

CMake Coding Style

gustavosbarreto edited this page Jul 6, 2011 · 4 revisions

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)