cart-elc

Source code for CART-ELC
git clone git://git.laack.co/cart-elc.git
Log | Files | Refs | README | LICENSE

MacroOptionalAddSubdirectory.cmake (1315B)


      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 
     19 macro (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})
     31 endmacro (MACRO_OPTIONAL_ADD_SUBDIRECTORY)