1# - Removes duplicate entries and non-directories from a provided list 2# 3# clean_directory_list(<listvar> [<additional list items>...]) 4# 5# Requires CMake 2.6 or newer (uses the 'function' command) 6# 7# Original Author: 8# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> 9# http://academic.cleardefinition.com 10# Iowa State University HCI Graduate Program/VRAC 11# 12# Copyright Iowa State University 2009-2010. 13# Distributed under the Boost Software License, Version 1.0. 14# (See accompanying file LICENSE_1_0.txt or copy at 15# http://www.boost.org/LICENSE_1_0.txt) 16 17if(__clean_directory_list) 18 return() 19endif() 20set(__clean_directory_list YES) 21 22function(clean_directory_list _var) 23 # combine variable's current value with additional list items 24 set(_in ${${_var}} ${ARGN}) 25 26 if(_in) 27 # Initial list cleaning 28 list(REMOVE_DUPLICATES _in) 29 30 # Grab the absolute path of each actual directory 31 set(_out) 32 foreach(_dir ${_in}) 33 if(IS_DIRECTORY "${_dir}") 34 get_filename_component(_dir "${_dir}" ABSOLUTE) 35 file(TO_CMAKE_PATH "${_dir}" _dir) 36 list(APPEND _out "${_dir}") 37 endif() 38 endforeach() 39 40 if(_out) 41 # Clean up the output list now 42 list(REMOVE_DUPLICATES _out) 43 endif() 44 45 # return _out 46 set(${_var} "${_out}" PARENT_SCOPE) 47 endif() 48endfunction() 49