且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

交叉编译时如何使用CMake管理安装目录?

更新时间:2022-06-25 03:48:21

sysroot与安装目录(前缀)之间没有没有干扰.

There is no interference between sysroot and install directory (prefix).

Sysroot由 CMAKE_SYSROOT 变量给出,表示构建过程中使用的工具的前缀.

Sysroot is given by CMAKE_SYSROOT variable and denotes prefix for tools used during build process.

安装目录(前缀)由 CMAKE_INSTALL_PREFIX 变量给出,并表示安装时将在其中使用项目的路径.例如.带有安装前缀/usr/local 的项目的可执行文件 foo 预计将以/usr/local/bin/foo 的身份运行.

Install directory(prefix) is given by CMAKE_INSTALL_PREFIX variable and denotes the path, where the project will be used upon installation. E.g. with install prefix /usr/local the project's executable foo expects to be run as /usr/local/bin/foo.

请注意,通过默认的安装过程,CMake将文件安装到主机计算机上.要将文件安装到目标计算机上,需要调整此过程.用于 make install 的参数 DESTDIR = xxx 是一种将文件直接安装到目标计算机的方法.另一种方法是在主机上创建一个程序包(例如,使用CPack),然后将该程序包安装在 target 计算机上.

Note, that with default installation procedure, CMake installs files to the host machine. For install files onto the target machine, this procedure is needed to be adjusted. Parameter DESTDIR=xxx for make install is a way for install files directly to the target machine. Another way is to create a package (e.g. with CPack) on host, and install that package on target machine.

请注意,在上段中,交叉编译是否已无关紧要:可以在一台计算机上构建项目并安装到另一个,但类似的一个,没有任何交叉编译.

Note, that in the above paragraph it is irrelevant, whether cross-compilation took a place or not: it is possible to build the project on one machine and install it to the other, but similar one, without any cross-compilation.