Show Menu
Cheatography

CMake Cheat Sheet (DRAFT) by

CMake

This is a draft cheat sheet. It is a work in progress and is not finished yet.

if command

if(exp­res­sion) endif()
if(exp­res­sion) else() endif()
if(exp­res­sion) else() elseif­(ex­pre­ssion2) endif()
True = 1, ON, YES, TRUE, Y, or a non-zero number.
False = 0, OFF, NO, FALSE, N, IGNORE, "­", or ends in the suffix '-NOTF­OUND'.
if(NOT expres­sion)
if(<ex­pr1> AND <ex­pr2­>)
if(<ex­pr1> OR <ex­pr2­>)
if(TARGET target­-name) True if the given name is an existing target, built or imported.
if(EXISTS full-p­ath­-fi­le-­name) if(EXISTS full-p­ath­-di­rec­tor­y-name)
if(IS_­DIR­ECTORY direct­ory­-name)
if(IS_­ABS­OLUTE path)

Add Custom...

add_cu­sto­m_c­ommand( OUTPUT output(s) COMMAND command arg(s) DEPENDS depend(s) WORKIN­G_D­IRE­CTORY dir COMMENT comment) This defines a command to generate specified OUTPUT file(s)
add_cu­sto­m_t­arget( name [ALL] DEPENDS depends-on ... )
add_cu­sto­m_c­omm­and­(TARGET target PRE_BUILD | PRE_LINK | POST_BUILD COMMAND command arg(s) WORKIN­G_D­IRE­CTORY dir COMMENT comment )