Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

CMake Coding Style

gustavosbarreto edited this page · 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)
Something went wrong with that request. Please try again.