cpack组件安装不起作用

时间:2017-11-02 16:53:10

标签: cmake cpack

我希望cpack只采用某些组件。但他同时兼顾了run和deb组件。我看了很多消息来源。包括这个cpack component level install。但我不明白我做错了什么。请告诉我,我做错了什么? 我的CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(testProj)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp)
add_executable(testProj ${SOURCE_FILES})

set(CMAKE_INSTALL_PREFIX .)

install(FILES temp.h DESTINATION someFolder
        PERMISSIONS OWNER_READ OWNER_WRITE WORLD_READ WORLD_EXECUTE COMPONENT deb
        )

install(FILES Alpha0.400000.txt DESTINATION someFolder
        PERMISSIONS OWNER_READ OWNER_WRITE WORLD_READ WORLD_EXECUTE COMPONENT run
        )

set(CPACK_TGZ_COMPONENT_INSTALL ON)
set(CPACK_COMPONENT_ALL deb)
set(CPACK_COMPONENTS_ALL deb)

include(CPack)

我获取工件的步骤

cmake . 
make 
cpack .

CPack: Create package using STGZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.sh generated.
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.tar.gz generated.
CPack: Create package using TZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.tar.Z generated.

和testProj-0.1.1-Linux.tar.gz包含

someFolder
   -temp.h
   -Alpha0.400000.txt

2 个答案:

答案 0 :(得分:0)

在这种情况下,我认为您应该在Cmake创建的package目标上调用make,而不是直接调用cpack,即调用make package而不是cpack .

或者,如果直接调用cpack,则可以将要打包的组件作为命令行参数传递。例如cpack -D CPACK_COMPONENTS_ALL="deb"(由';'为多个组件分隔)

(请注意,正确的变量为CPACK_COMPONENTS_ALL而不是CPACK_COMPONENT_ALL

答案 1 :(得分:0)

只需将以下内容添加到您的CMakeLists.txt

Friend

我遇到了完全相同的问题,不得不深入调查源头来寻找答案。以下功能给出了答案:

const User = require('../../database/models/User')
const Friend = require('../../database/models/Friend')

module.exports = async (req, res) => {
    let userData = []
    await Friend.find({}, (err, friends) => {
        if (!err) {
            let friendData
            friends.forEach(async friend => {
                friendData = await User.findOne({
                    accountId: friend.accountId
                }).sort('-dateAdded').then(data => {
                    data.mainDevice = friend.mainDevice
                    userData.push(JSON.stringify(data))
                }).catch(err => {
                    console.log(err)
                })
            });
        }
    })

    res.render('layouts/chart-list-v2', {
        userData: userData
    })
}

出于兼容性原因,任何归档文件包装(即ZIP和TGZ)均不使用组件安装。