aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2014-11-05 08:50:00 -0500
committerJohn Szakmeister <john@szakmeister.net>2014-11-08 16:55:15 -0500
commit938faf5e2d49a5ea7458eefbc0e0df0532d01d32 (patch)
tree1d3c9a789f198c9d040633ee91e9dd37b1385ad2
parente0628dab497fbfa62f0ab2dcc3d7eb785b5cc137 (diff)
downloadrneovim-938faf5e2d49a5ea7458eefbc0e0df0532d01d32.tar.gz
rneovim-938faf5e2d49a5ea7458eefbc0e0df0532d01d32.tar.bz2
rneovim-938faf5e2d49a5ea7458eefbc0e0df0532d01d32.zip
build: fix the usage of DESTDIR in InstallHelpers.cmake
It turns out that `file(INSTALL ...)` already accounts for `DESTDIR`, so this wasn't creating the directory structure in the correct location. Instead, we need to do our existence check with `DESTDIR`, but leave it off when doing the install step. While we're at it, add a check to make sure `ENV{DESTDIR}` is not being used with a relative path, as that construct doesn't make much sense. This fixes issue #1387 discovered while trying to make helptag generation work correctly in #1381.
-rw-r--r--cmake/InstallHelpers.cmake18
1 files changed, 11 insertions, 7 deletions
diff --git a/cmake/InstallHelpers.cmake b/cmake/InstallHelpers.cmake
index a23bf63ab3..763b2a092c 100644
--- a/cmake/InstallHelpers.cmake
+++ b/cmake/InstallHelpers.cmake
@@ -22,19 +22,21 @@ function(create_install_dir_with_perms)
install(CODE
"
- if(ENV{DESTDIR})
- # TODO(fwalch): Is this branch ever taken (#1381, #1387)?
- set(PREFIX \$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX})
- else()
- set(PREFIX \${CMAKE_INSTALL_PREFIX})
+ if(DEFINED ENV{DESTDIR} AND NOT IS_ABSOLUTE \${CMAKE_INSTALL_PREFIX})
+ message(FATAL_ERROR \"Install prefix must be absolute when using DESTDIR\")
endif()
- set(_current_dir \"\${PREFIX}/${_install_dir_DESTINATION}\")
+ set(_current_dir \"\${CMAKE_INSTALL_PREFIX}/${_install_dir_DESTINATION}\")
set(_dir_permissions \"${_install_dir_DIRECTORY_PERMISSIONS}\")
set(_parent_dirs)
- while(NOT EXISTS \${_current_dir})
+ 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()
@@ -47,6 +49,8 @@ function(create_install_dir_with_perms)
# 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}