Cmake不尊重CMAKE_INSTALL_PREFIX的值

时间:2018-03-29 09:48:01

标签: build cmake installation gnu-make awesome-wm

我正在尝试从源代码安装wesome wm。所以我创建了一个构建目录并执行了以下命令:

cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX

但是make install尝试将一些程序文件放在/usr/local/share中,这不是我想要的地方:

> make install
[  3%] Built target generated_sources
[  6%] Built target test-gravity
[  9%] Built target lgi-check
[  9%] Built target version_stamp
[ 29%] Built target generated_icons
[ 31%] Checking for LGI...
Building for Lua 5.3.
Found lgi 0.9.2.
[ 31%] Built target lgi-check-run
[ 35%] Built target generate_awesomerc
[100%] Built target awesome
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/user/.local/bin/awesome
-- Up-to-date: /home/user/.local/bin/awesome-client
-- Installing: /usr/local/share/awesome/lib
CMake Error at cmake_install.cmake:69 (file):
  file INSTALL cannot make directory "/usr/local/share/awesome/lib": No such
  file or directory


make: *** [Makefile:107: install] Error 1

我需要为CMAKE_INSTALL_PREFIX数据指定一些类似于CMAKE_INSTALL_LIBDIRshare的cmake变量吗?

1 个答案:

答案 0 :(得分:2)

使用cmake模块时,您CMAKE_INSTALL_DATADIR share:include(GNUInstallDirs

注意:使用cmake --build build --target install -- DESTDIR=foo时 请阅读CMAKE_INSTALL_PREFIX doc

  

在UNIX上,可以使用DESTDIR机制重新定位整个安装。 DESTDIR意味着DESTination DIRectory。

     

警告:DESTDIR可能不会在Windows上使用,因为安装前缀通常包含类似于C:/ Program Files的驱动器号,这些驱动器号不能添加其他前缀。

src:https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html#variable:CMAKE_INSTALL_PREFIX

相关问题