How do you control the location of header files in

2019-07-11 05:45发布

I'm installing a package that was built with CMake. It installs header files in a nonstandard location. Is there a variable I can use at installation time to change that path?

The current CMake invocation is:

cmake /p/a/t/h -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib

I'm looking for -DCMAKE_INSTALL_INCDIR or -DCMAKE_INCLUDE_DIR or -DCMAKE_INCLUDE_HEADERDIR, or something. (For example, I'm trying to accomplish what would be done with configure --includedir=/usr/include using an autoconf generated configure script.)

标签: cmake
1条回答
劫难
2楼-- · 2019-07-11 05:50

Generally, CMake packages needn't to allow user to modify installation paths on per-component basis.

But if the package includes CMake module GNUInstallDirs and uses variables from it for install components, user may affect on components' installation paths by setting some of these variables. Each such variable has a form

CMAKE_INSTALL_<dir>

where <dir> may be on of (according to the documentation):

BINDIR           - user executables (bin)
SBINDIR          - system admin executables (sbin)
LIBEXECDIR       - program executables (libexec)
SYSCONFDIR       - read-only single-machine data (etc)
SHAREDSTATEDIR   - modifiable architecture-independent data (com)
LOCALSTATEDIR    - modifiable single-machine data (var)
LIBDIR           - object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian)
INCLUDEDIR       - C header files (include)
OLDINCLUDEDIR    - C header files for non-gcc (/usr/include)
DATAROOTDIR      - read-only architecture-independent data root (share)
DATADIR          - read-only architecture-independent data (DATAROOTDIR)
INFODIR          - info documentation (DATAROOTDIR/info)
LOCALEDIR        - locale-dependent data (DATAROOTDIR/locale)
MANDIR           - man documentation (DATAROOTDIR/man)
DOCDIR           - documentation root (DATAROOTDIR/doc/PROJECT_NAME)

Note, that the package needn't to use all of these variables. E.g., the package may use variable CMAKE_INSTALL_LIBDIR for install libraries, but ignore CMAKE_INSTALL_INCLUDEDIR when install headers.

查看更多
登录 后发表回答