Skip to content

Commit

Permalink
Use explicit INSTALL_COMMAND to suppress DESTDIR (#21)
Browse files Browse the repository at this point in the history
The DESTDIR environment variable is used on UNIX systems during an
invocation of 'make install' to specify an alternate directory prefix
for installation paths. Since this isn't a cross-platform mechanism,
the CMAKE_INSTALL_PREFIX CMake variable can also be used.

Unfortunately, if both of these are specified, they will both be
applied. This isn't typically a problem, but can cause problems for the
installation phase of ExternalProject_Add if the external project is
built during an invocation of 'make install' with DESTDIR set.

Since the CMAKE_INSTALL_PREFIX method is employed by the call to
ExternalProject_Add instead of DESTDIR, we should specifically suppress
DESTDIR if it is set so that it doesn't interfere with the installation
of the external project to the staging directory.

Signed-off-by: Scott K Logan <logans@cottsay.net>
  • Loading branch information
cottsay authored Feb 1, 2021
1 parent c614081 commit ca32b1e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ macro(build_uncrustify)
-Wno-dev
PATCH_COMMAND
${CMAKE_COMMAND} -E chdir <SOURCE_DIR> git checkout -q . && ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> git apply -p1 --ignore-space-change --whitespace=nowarn ${CMAKE_CURRENT_SOURCE_DIR}/install-patch.diff
# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/18165,
# which is exacerbated by https://gitlab.kitware.com/cmake/cmake/-/issues/16419.
# We're configuring the project to use CMAKE_INSTALL_PREFIX, so we never want
# DESTDIR to affect it.
INSTALL_COMMAND
${CMAKE_COMMAND} -E env DESTDIR= ${CMAKE_COMMAND} --install .
)

# The external project will install to the build folder, but we'll install that on make install.
Expand Down

0 comments on commit ca32b1e

Please sign in to comment.