install(CODE
"
set(_current_dir \"\${CMAKE_INSTALL_PREFIX}/${_install_dir_DESTINATION}\")
set(_dir_permissions \"${_install_dir_DIRECTORY_PERMISSIONS}\")
set(_parent_dirs)
set(_prev_dir)
# Explicitly prepend DESTDIR when using EXISTS.
# file(INSTALL ...) implicitly respects DESTDIR, but EXISTS does not.
while(NOT EXISTS \$ENV{DESTDIR}\${_current_dir} AND NOT \${_prev_dir} STREQUAL \${_current_dir})
list(APPEND _parent_dirs \${_current_dir})
set(_prev_dir \${_current_dir})
get_filename_component(_current_dir \${_current_dir} PATH)
endwhile()
if(_parent_dirs)
list(REVERSE _parent_dirs)
endif()
# Create any missing folders with the useful permissions. Note: this uses
# a hidden option of CMake, but it's been shown to work with 2.8.11 thru
# 3.0.2.
foreach(_current_dir \${_parent_dirs})
if(NOT IS_DIRECTORY \${_current_dir})
# file(INSTALL ...) implicitly respects DESTDIR, so there's no need to
# prepend it here.
file(INSTALL DESTINATION \${_current_dir}
TYPE DIRECTORY
DIR_PERMISSIONS \${_dir_permissions}
FILES \"\")
endif()
endforeach()
")