1# - MACRO_OPTIONAL_ADD_SUBDIRECTORY() combines ADD_SUBDIRECTORY() with an OPTION() 2# MACRO_OPTIONAL_ADD_SUBDIRECTORY( <dir> ) 3# If you use MACRO_OPTIONAL_ADD_SUBDIRECTORY() instead of ADD_SUBDIRECTORY(), 4# this will have two effects 5# 1 - CMake will not complain if the directory doesn't exist 6# This makes sense if you want to distribute just one of the subdirs 7# in a source package, e.g. just one of the subdirs in kdeextragear. 8# 2 - If the directory exists, it will offer an option to skip the 9# subdirectory. 10# This is useful if you want to compile only a subset of all 11# directories. 12 13# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org> 14# 15# Redistribution and use is allowed according to the terms of the BSD license. 16# For details see the accompanying COPYING-CMAKE-SCRIPTS file. 17 18 19MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) 20 GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) 21 IF(EXISTS ${_fullPath}) 22 IF(${ARGC} EQUAL 2) 23 OPTION(BUILD_${_dir} "Build directory ${_dir}" ${ARGV1}) 24 ELSE(${ARGC} EQUAL 2) 25 OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE) 26 ENDIF(${ARGC} EQUAL 2) 27 IF(BUILD_${_dir}) 28 ADD_SUBDIRECTORY(${_dir}) 29 ENDIF(BUILD_${_dir}) 30 ENDIF(EXISTS ${_fullPath}) 31ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY) 32