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