Makefile not recognizing DESTDIR variable
I’m trying to install moab to a specific directory using make DESTDIR=/path/to/install/dir install
, which is required when writing a PKGBUILD script in the Arch User Repository (AUR, see here). This works partially, and then fails when it looks for libraries just using the CMAKE_INSTALL_PREFIX
and doesn’t check for the DESTDIR
variable. See sample output below from my system (manjaro)
Install the project...
-- Install configuration: ""
-- Installing: /mnt/moab/pkg/moab/opt/MOAB/lib/cmake/MOAB/MOABTargets.cmake
-- Installing: /mnt/moab/pkg/moab/opt/MOAB/lib/cmake/MOAB/MOABTargets-noconfig.cmake
-- Installing: /mnt/moab/pkg/moab/opt/MOAB/lib/iMesh-Defs.inc
-- Installing: /mnt/moab/pkg/moab/opt/MOAB/lib/moab.make
CMake Error at cmake_install.cmake:77 (file):
file failed to open for writing (No such file or directory):
/opt/MOAB/lib/moab.make
make: *** [Makefile:110: install] Error 1
So here, /opt/MOAB
is the CMAKE_INSTALL_PREFIX, and DESTDIR is /mnt/moab/pkg/moab.
On line 77 (and line 81) of `cmake_install.cmake`, which can be found in the build folder after cmake
is run, there is a hardcoded filepath, instead of the DESTDIR
filepath. See below
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
file(APPEND /home/luke/git/openmc_install_scripts/Arch/AUR/MOAB-PKGBUILD/pkg/moab/opt/MOAB/lib/moab.make MOAB_LIBDIR=/home/luke/git/openmc_install_scripts/Arch/AUR/MOAB-PKGBUILD/pkg/moab/opt/MOAB/lib\n )
endif()
if(CMAKE_INSTALL_COMPONENT STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
file(APPEND /home/luke/git/openmc_install_scripts/Arch/AUR/MOAB-PKGBUILD/pkg/moab/opt/MOAB/lib/moab.make MOAB_INCLUDES=-I/home/luke/git/openmc_install_scripts/Arch/AUR/MOAB-PKGBUILD/pkg/moab/opt/MOAB/include\n )
endif()
Whereas the others all include the INSTALL DESTINATION
and CMAKE_INSTALL_PREFIX
variables, which results in proper behaviour. I think this is the root of the issue, but I’m not sure how to resolve it.
In the meantime, would there be a way around this issue just using cmake? Or will it require a fix?
Comments (3)
-
reporter -
Sorry, I missed this issue. If you want to submit a quick PR, please do. Else, I’ll try to apply this patch and run it through our CI before submitting a PR for it this weekend.
-
- changed status to resolved
Fixed in
#25ed1b2 on 2023-04-14 - Log in to comment
I was able to get around this issue with the following patch
Is there a reason to use CMAKE_INSTALL_FULL_LIBDIR instead of CMAKE_INSTALL_LIBDIR? Or could this be a quick PR?