2013-05-21 110 views
2

對於附加到CMake wiki的CMakeLists.txt示例。我還在下面添加了什麼是實際的make命令來創建基於TGZ的組件。我很困惑,沒有看到任何文件的幫助。cpack組件級別安裝

的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

看看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

對不起,我是個新手太多,不能幫你了。

0

這很簡單。 只需將CMAKE變量CPACK_COMPONENTS_ALL設置爲您要在安裝中顯示的組件列表:

SET(CPACK_COMPONENTS_ALL applications) #only pack "applications" component