mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-04 21:08:03 +00:00
cmake: Add missing modules
This commit is contained in:
parent
1aff19e975
commit
6b0831466e
48
cmake/CleanDirectoryList.cmake
Normal file
48
cmake/CleanDirectoryList.cmake
Normal file
|
@ -0,0 +1,48 @@
|
|||
# - Removes duplicate entries and non-directories from a provided list
|
||||
#
|
||||
# clean_directory_list(<listvar> [<additional list items>...])
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__clean_directory_list)
|
||||
return()
|
||||
endif()
|
||||
set(__clean_directory_list YES)
|
||||
|
||||
function(clean_directory_list _var)
|
||||
# combine variable's current value with additional list items
|
||||
set(_in ${${_var}} ${ARGN})
|
||||
|
||||
if(_in)
|
||||
# Initial list cleaning
|
||||
list(REMOVE_DUPLICATES _in)
|
||||
|
||||
# Grab the absolute path of each actual directory
|
||||
set(_out)
|
||||
foreach(_dir ${_in})
|
||||
if(IS_DIRECTORY "${_dir}")
|
||||
get_filename_component(_dir "${_dir}" ABSOLUTE)
|
||||
file(TO_CMAKE_PATH "${_dir}" _dir)
|
||||
list(APPEND _out "${_dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_out)
|
||||
# Clean up the output list now
|
||||
list(REMOVE_DUPLICATES _out)
|
||||
endif()
|
||||
|
||||
# return _out
|
||||
set(${_var} "${_out}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
36
cmake/PrefixListGlob.cmake
Normal file
36
cmake/PrefixListGlob.cmake
Normal file
|
@ -0,0 +1,36 @@
|
|||
# - For each given prefix in a list, glob using the prefix+pattern
|
||||
#
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__prefix_list_glob)
|
||||
return()
|
||||
endif()
|
||||
set(__prefix_list_glob YES)
|
||||
|
||||
function(prefix_list_glob var pattern)
|
||||
set(_out)
|
||||
set(_result)
|
||||
foreach(prefix ${ARGN})
|
||||
file(GLOB _globbed ${prefix}${pattern})
|
||||
if(_globbed)
|
||||
list(SORT _globbed)
|
||||
list(REVERSE _globbed)
|
||||
list(APPEND _out ${_globbed})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(_name ${_out})
|
||||
get_filename_component(_name "${_name}" ABSOLUTE)
|
||||
list(APPEND _result "${_name}")
|
||||
endforeach()
|
||||
|
||||
set(${var} "${_result}" PARENT_SCOPE)
|
||||
endfunction()
|
85
cmake/ProgramFilesGlob.cmake
Normal file
85
cmake/ProgramFilesGlob.cmake
Normal file
|
@ -0,0 +1,85 @@
|
|||
# - Find bit-appropriate program files directories matching a given pattern
|
||||
#
|
||||
# Requires these CMake modules:
|
||||
# CleanDirectoryList
|
||||
# PrefixListGlob
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
include(PrefixListGlob)
|
||||
include(CleanDirectoryList)
|
||||
|
||||
if(__program_files_glob)
|
||||
return()
|
||||
endif()
|
||||
set(__program_files_glob YES)
|
||||
|
||||
macro(_program_files_glob_var_prep)
|
||||
# caution - ENV{ProgramFiles} on Win64 is adjusted to point to the arch
|
||||
# of the running executable which, since CMake is 32-bit on Windows as
|
||||
# I write this, will always be = $ENV{ProgramFiles(x86)}.
|
||||
# Thus, we only use this environment variable if we are on a 32 machine
|
||||
|
||||
# 32-bit dir on win32, useless to us on win64
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES)
|
||||
|
||||
# 32-bit dir: only set on win64
|
||||
set(_PF86 "ProgramFiles(x86)")
|
||||
file(TO_CMAKE_PATH "$ENV{${_PF86}}" _PROG_FILES_X86)
|
||||
|
||||
# 64-bit dir: only set on win64
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" _PROG_FILES_W6432)
|
||||
endmacro()
|
||||
|
||||
function(program_files_glob var pattern)
|
||||
_program_files_glob_var_prep()
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
# 64-bit build on win64
|
||||
set(_PROGFILESDIRS "${_PROG_FILES_W6432}")
|
||||
else()
|
||||
if(_PROG_FILES_W6432)
|
||||
# 32-bit build on win64
|
||||
set(_PROGFILESDIRS "${_PROG_FILES_X86}")
|
||||
else()
|
||||
# 32-bit build on win32
|
||||
set(_PROGFILESDIRS "${_PROG_FILES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
prefix_list_glob(_prefixed "${pattern}" ${_PROGFILESDIRS})
|
||||
clean_directory_list(_prefixed)
|
||||
set(${var} ${_prefixed} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(program_files_fallback_glob var pattern)
|
||||
_program_files_glob_var_prep()
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
# 64-bit build on win64
|
||||
# look in the "32 bit" (c:\program files (x86)\) directory as a
|
||||
# fallback in case of weird/poorly written installers, like those
|
||||
# that put both 64- and 32-bit libs in the same program files directory
|
||||
set(_PROGFILESDIRS "${_PROG_FILES_W6432}" "${_PROG_FILES_X86}")
|
||||
else()
|
||||
if(_PROG_FILES_W6432)
|
||||
# 32-bit build on win64
|
||||
# look in the "64 bit" (c:\program files\) directory as a fallback
|
||||
# in case of old/weird/poorly written installers
|
||||
set(_PROGFILESDIRS "${_PROG_FILES_X86}" "${_PROG_FILES_W6432}")
|
||||
else()
|
||||
# 32-bit build on win32
|
||||
set(_PROGFILESDIRS "${_PROG_FILES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
prefix_list_glob(_prefixed "${pattern}" ${_PROGFILESDIRS})
|
||||
clean_directory_list(_prefixed)
|
||||
set(${var} ${_prefixed} PARENT_SCOPE)
|
||||
endfunction()
|
Loading…
Reference in a new issue