【问题标题】:Install headers in corresponding directories在相应目录中安装标头
【发布时间】:2018-12-05 06:55:38
【问题描述】:

我正在尝试使用 QMake 安装我的库的标头。这些标头给出了必须应用于安装目标的层次顺序。我目前的解决方案是添加许多目标(每个目标对应一个子目录):

...
headers.path = /usr/include/foo/widgets
headers_base.path = /usr/include/foo/widgets
headers_data.path = /usr/include/foo/widgets/data
headers_editors.path = /usr/include/foo/widgets/editors
...
HEADERS_BASE += \
    foo.hpp \
    bar.hpp
HEADERS_DATA += \
    data/foo.hpp \
    data/bar.hpp
HEADERS_EDITORS += \
    editors/foo.hpp \
    editors/bar.hpp
...
HEADERS += $$HEADERS_BASE \
    $$HEADERS_DATA \
    $$HEADERS_EDITORS

这是乏味和错误修剪。我想在 autotools 中使用像nobase 这样简单直接的东西。像这样的:

magic_HEADERS += \
    foo.hpp \
    bar.hpp
    data/foo.hpp \
    data/bar.hpp
    editors/foo.hpp \
    editors/bar.hpp

注意

HEADERS += \
    foo.hpp \
    bar.hpp
    data/foo.hpp \
    data/bar.hpp
    editors/foo.hpp \
    editors/bar.hpp

将所有头文件安装在一个目录中。

【问题讨论】:

    标签: header-files qmake build-system


    【解决方案1】:

    如果您更改 .pro 文件,将安装头文件,例如:

    HEADERS += \
        include/widgets/foo.hpp \
        include/widgets/bar.hpp \
        include/widgets/data/foo.hpp \
        include/widgets/data/bar.hpp \
        include/widgets/editors/foo.hpp \
        include/widgets/editors/bar.hpp
    
    unix {
        headers.path = /usr/local/include
        headers.files = $$PWD/include/*
    
        target.path = /usr/local/lib
        INSTALLS += target headers
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-30
      • 1970-01-01
      • 2022-12-18
      • 2023-01-25
      • 1970-01-01
      • 2017-05-21
      • 2017-05-16
      相关资源
      最近更新 更多