The open source OpenXR runtime
at main 51 lines 1.3 kB view raw
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 Rylie Pavlik <rylie@ryliepavlik.com> 9# https://ryliepavlik.com/ 10# Iowa State University HCI Graduate Program/VRAC 11# 12# Copyright 2009-2010, Iowa State University. 13# 14# Distributed under the Boost Software License, Version 1.0. 15# (See accompanying file LICENSE_1_0.txt or copy at 16# http://www.boost.org/LICENSE_1_0.txt) 17# 18# SPDX-License-Identifier: BSL-1.0 19 20if(__clean_directory_list) 21 return() 22endif() 23set(__clean_directory_list YES) 24 25function(clean_directory_list _var) 26 # combine variable's current value with additional list items 27 set(_in ${${_var}} ${ARGN}) 28 29 if(_in) 30 # Initial list cleaning 31 list(REMOVE_DUPLICATES _in) 32 33 # Grab the absolute path of each actual directory 34 set(_out) 35 foreach(_dir ${_in}) 36 if(IS_DIRECTORY "${_dir}") 37 get_filename_component(_dir "${_dir}" ABSOLUTE) 38 file(TO_CMAKE_PATH "${_dir}" _dir) 39 list(APPEND _out "${_dir}") 40 endif() 41 endforeach() 42 43 if(_out) 44 # Clean up the output list now 45 list(REMOVE_DUPLICATES _out) 46 endif() 47 48 # return _out 49 set(${_var} "${_out}" PARENT_SCOPE) 50 endif() 51endfunction()