Exporter.cmake

Provides support for generating CMake packages from dynamic, static and header library products. More...

Since: Qbs 2.3

Properties

Detailed Description

The Exporter.cmake module contains the properties and rules to create a CMake config files from the Export item of a Product.

For instance, suppose you are creating a library. To allow exporting to CMake, you would write something like the following:

DynamicLibrary {
    name: "mylibrary"
    qbs.installPrefix: "/opt/mylibrary"
    Depends { name: "Exporter.cmake" }
    Exporter.cmake.packageName: "MyLibrary"
    property string headersInstallDir: "include"
    // ...
    Group {
        name: "API headers"
        files: ["mylib.h"]
        qbs.install: true
        qbs.installDir: headersInstallDir
    }
    Group {
        fileTagsFilter: ["Exporter.cmake.package"]
        qbs.installDir: "lib/cmake/MyLibrary"
    }
    Export {
        Depends { name: "cpp" }
        cpp.includePaths: FileInfo.joinPaths(
            exportingProduct.qbs.installRoot,
            exportingProduct.qbs.installPrefix,
            exportingProduct.headersInstallDir)
    }
}

To build against this library, from within your CMake project, you simply use find_package:

find_package(MyLibrary PATHS REQUIRED)
add_executable(Consumer main.cpp)
target_link_libraries(Consumer MyLibrary)

Relevant File Tags

TagSinceDescription
"Exporter.cmake.package"2.3.0This tag is attached to all generated module files.
"Exporter.cmake.configFile"2.3.0This tag is attached to the generated config file.
"Exporter.cmake.versionFile"2.3.0This tag is attached to the generated version file.

Property Documentation

configFileName : string

The name of the generated config file.

Default: packageName + "Config.cmake"


packageName : string

The name of the CMake package.

Default: Product.targetName


versionFileName : string

The name of the generated version file.

Default: packageName + "ConfigVersion.cmake"


© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.