如何启用cmake从安装排除子目录? [英] How to enable cmake to exclude a subdirectory from install?
问题描述
我一直在尝试在RHEL 6.4框上为 libc ++
3.3创建 RPM
我需要静态和共享库。所以,我学习了一些 cmake
的基础知识,然后修改了捆绑的 CMakeList.txt
。
I have been trying to build RPM
packages for libc++
3.3 on a RHEL 6.4 box. I need both static and shared libraries. So, I learned some basics of cmake
and then modified the bundled CMakeList.txt
. Got that part to work.
但是由于在RHEL 6.x中,所有64位库都应该转到 / usr / lib64
而不是 / usr / lib
,我一直在尝试使用下面的工作完成:
But since in RHEL 6.x, all 64-bit libraries should go to /usr/lib64
instead of /usr/lib
, I have been attempting to use the following to get the job done:
(A)在建立期间,我使用
(A) During building, I use
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
以拥有所有库文件( * .so *
,而不是
lib
>。
to have all library files (*.so*
and *.a
) located in lib64
rather than lib
.
(B)使用 ADD_LIBRARY ...
命令,如下所示
(B) Using a ADD_LIBRARY...
command as shown below
ADD_LIBRARY(c++ STATIC ...
和
set_target_properties(c++ PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
INSTALL(TARGETS c++
ARCHIVE DESTINATION lib${LIB_SUFFIX})
静态库安装在 / usr / lib64
中。
(C)此外,使用
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libc++.so DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libc++.so.1 DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libc++.so.1.0 DESTINATION lib${LIB_SUFFIX})
也要在 / usr / lib64
中安装共享库。
但共享库的副本仍然安装在生成的RPM中的 / usr / lib
中。如何防止它?
But a copy of the shared library is still installed in /usr/lib
in the resulting RPM. How can I prevent it?
如果我要写一个RPM spec
文件, _libdir
宏自动处理这个。使用 cmake
,鉴于我还是新的,我将欣赏一个关于使用正确指令的提示/指针。
If I were to write a RPM spec
file, the _libdir
macro automatically handles this. With cmake
, given the fact that I am still new to it, I would appreciate a hint/pointer as to the right directive to use.
推荐答案
实际上,在 cmake
邮件列表中有帮助的人,我现在可以摆脱在 spec
文件中创建%dir / usr / lib
它实际上很简单:只需cd到 $ CMAKE_SOURCE_DIR / lib
并编辑 CMakeLists.txt
。将 $ {LIB_SUFFIX}
附加到两个安装 DESTINATION
。重新生成 build
子目录中的 Makefile
,然后重新生成 make& make package
。所有库文件根据需要进入 / usr / lib64
。
Actually, with a helpful person in the cmake
mailing list, I am now able to rid of the %dir /usr/lib
in the generated spec
file. It's actually quite simple: just cd to $CMAKE_SOURCE_DIR/lib
and edit the CMakeLists.txt
there. Append ${LIB_SUFFIX}
to the two install DESTINATION
s. Regenerate the Makefile
in the build
subdirectory, and then make && make package
. All library files go into /usr/lib64
as desired.
这篇关于如何启用cmake从安装排除子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!