Here is a somewhat cleaned up version of TWXS's code: https://gist.github.com/DanTheColoradan/22bf1ca6307b8edcb53e
if (NOT INSTALLING) set (WORKING DIRECTORY "${CMAKECURRENTBINARYDIR}/Install") file (MAKEDIRECTORY "${DIRECTORY}") executeprocess (COMMAND "${CMAKECOMMAND}" -DINSTALLING=TRUE -DINSTALLPREFIX=${MYINSTALLPREFIX} "${CMAKECURRENTSOURCEDIR}" WORKING_DIRECTORY "${DIRECTORY}" ) executeprocess (COMMAND "${CMAKECOMMAND}" --build . --config Release WORKING_DIRECTORY "${DIRECTORY}" ) else (NOT INSTALLING) project ("") include (ExternalProject) ExternalProjectAdd (externalproject GITREPOSITORY "<gitrepourl>" INSTALLDIR "${INSTALLPREFIX}" CMAKEARGS -DCMAKEINSTALLPREFIX:PATH= ) endif (NOT INSTALLING)
Here is a somewhat cleaned up version of TWXS's code:
https://gist.github.com/DanTheColoradan/22bf1ca6307b8edcb53e