Generate two different package using CPack in cmake : Linux

拥有回忆 提交于 2019-12-07 11:07:06

问题


I want to create two different package for my project.

  1. DCM (Includes all the modules except RCM specific module )
  2. RCM (Specific Module.)

1. DCM : src/CMakeList.txt

cmake_minimum_required (VERSION 2.8)

add_subdirectory(ecs) # Include all modules

set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_NAME "dcm")
set(CPACK_PACKAGE_VENDOR "AB")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Device Control")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set(CPACK_PACKAGE_VERSION_BUILD ${BUILD_NUMBER})

set(CPACK_COMPONENTS_ALL DCM RCM )

# Include CPack to introduce the appropriate targets
include(CPack)

2. RCM : src/ecs/mqa/mqa_rcm/CMakeList.txt

set(RCM_SCRIPTS 
commit.sh
install.sh
prepare_for_install.sh
system_check.sh
update_init.sh)

INSTALL(FILES ${RCM_SCRIPTS}
        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE  WORLD_EXECUTE
        DESTINATION ${RCM_INSTALL_PREFIX}/install
        COMPONENT RCM )
# Create version file
install(FILES "${CMAKE_BINARY_DIR}/version" 
        DESTINATION ${RCM_INSTALL_PREFIX}
        COMPONENT RCM )

Try Out : On Linux virtual machine prompt.

$make -j4
$make install
$make package

It creates only single package DCM-1.90.0-Linux.tar.gz.

Reference : CMake Wiki and CPack and StackOverflow

Problem : I want to create 1. DCM-1.90.0-Linux.tar.gz and 2. RCM-1.90.0-Linux.tar.gz package.

I googled but, unable to find exact solution.

Let me know in case of you want more information.

Many Thanks in advance.


回答1:


I just need to set CPACK flag ON.

set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

just before

include(CPack)

And run command.

make
make install
make package

And it creates two different packages.




回答2:


I don't use CPack, so maybe there is a better solution than the following.

For my different installations, I define some variables in CACHE (for example : set(INCLUDE_MODULE_XYZ OFF CACHE BOOL "Include the module xyz")) defining what I put in my installation. You can change the value of this variable running ccmake.

In your case, you can generate your first package, change de configuration with ccmake, and then generate the second package (if needed).



来源:https://stackoverflow.com/questions/28671524/generate-two-different-package-using-cpack-in-cmake-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!