附加到CMake wiki的示例CMakeLists.txt。我还在下面添加了什么是实际的make命令来创建基于组件的TGZ。我很困惑,没有在文件中看到任何帮助。
的CMakeLists.txt
cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
project(MyLib)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix prepended on to install directories." FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CPACK_PACKAGE_NAME "MyLib")
set(CPACK_PACKAGE_VENDOR "CMake.org")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
set(CPACK_PACKAGE_VERSION "1.0.0")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
add_library(mylib mylib.cpp)
add_executable(mylibapp mylibapp.cpp)
target_link_libraries(mylibapp mylib)
install(TARGETS mylib
ARCHIVE
DESTINATION lib
COMPONENT libraries)
install(TARGETS mylibapp
RUNTIME
DESTINATION bin
COMPONENT applications)
install(FILES mylib.h
DESTINATION include
COMPONENT headers)
set(CPACK_COMPONENTS_ALL applications libraries headers)
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "MyLib Application")
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
"An extremely useful application that makes use of MyLib")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
"Static libraries used to build programs with MyLib")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
"C/C++ header files for use with MyLib")
set(CPACK_GENERATOR "TGZ")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_CONTACT "jhf")
# This must always be last!
include(CPack)
我有一个类似的CMakeLists.txt,当我做make package
时,我最终得到了TGZ中的所有二进制文件和库。如果我只需要一个带有上述CMakeLists.txt中的应用程序组件的TGZ,make package命令应该是什么?
答案 0 :(得分:1)
很简单。 只需将CMAKE变量CPACK_COMPONENTS_ALL设置为要在安装中显示的组件列表:
SET(CPACK_COMPONENTS_ALL applications) #only pack "applications" component
答案 1 :(得分:0)
看看CPackComponent。
我和你有完全相同的问题。
我是cmake的初学者,今天我已经尝试了一整天,刚才我注意到一个名为CPackComponent的cmake模块开始出现在cmake 2.8.5标准模块中。
目前,我尚未确定是否是原因。但是您列出的文档中的变量可以在此模块中找到。
cmake 2.8.5是其标准模块中包含CPackComponent的最早版本。
在http://www.cmake.org/cmake/help/v2.8.5/cmake.html#module:CPackComponent
进行检查cmake 2.8.8是最早列出你想要的变量的版本。例如CPACK_COMPONENTS_ALL
在这里http://www.cmake.org/cmake/help/v2.8.8/cmake.html#module:CPackComponent
对不起我也是新手,再也帮不了你了。