简体   繁体   English

在cmake中使用CPack生成两个不同的包:Linux

[英]Generate two different package using CPack in cmake : Linux

I want to create two different package for my project. 我想为我的项目创建两个不同的包。

  1. DCM (Includes all the modules except RCM specific module ) DCM(包括RCM特定模块以外的所有模块)
  2. RCM (Specific Module.) RCM(特定模块。)

1. DCM : src/CMakeList.txt 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 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. 试用:在Linux虚拟机提示符下。

$make -j4
$make install
$make package

It creates only single package DCM-1.90.0-Linux.tar.gz . 它只创建单个包DCM-1.90.0-Linux.tar.gz

Reference : CMake Wiki and CPack and StackOverflow 参考: CMake WikiCPack以及StackOverflow

Problem : I want to create 1. DCM-1.90.0-Linux.tar.gz and 2. RCM-1.90.0-Linux.tar.gz package. 问题:我想创建1. DCM-1.90.0-Linux.tar.gz和2. RCM-1.90.0-Linux.tar.gz包。

I googled but, unable to find exact solution. 我用谷歌搜索,但无法找到确切的解决方案。

Let me know in case of you want more information. 如果您需要更多信息,请告诉我。

Many Thanks in advance. 提前谢谢了。

I just need to set CPACK flag ON. 我只需要将CPACK标志设置为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. 它创建了两个不同的包。

I don't use CPack, so maybe there is a better solution than the following. 我不使用CPack,所以可能有比以下更好的解决方案。

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. 对于我的不同安装,我在CACHE中定义了一些变量(例如: set(INCLUDE_MODULE_XYZ OFF CACHE BOOL "Include the module xyz") )定义我在安装中放入的内容。 You can change the value of this variable running ccmake. 您可以更改运行ccmake的此变量的值。

In your case, you can generate your first package, change de configuration with ccmake, and then generate the second package (if needed). 在您的情况下,您可以生成第一个包,使用ccmake更改配置,然后生成第二个包(如果需要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM