Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make a library with the installed layout looks like Qt's internal modules (a.k. QtCore, QtQml, ect.)?
Forum Updated to NodeBB v4.3 + New Features

How to make a library with the installed layout looks like Qt's internal modules (a.k. QtCore, QtQml, ect.)?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 127 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sauntor
    wrote on last edited by
    #1

    Environment

    • CMake
    • Ubuntu 24.04
    • Qt 6.8.1/Online Installer

    Case

    I have wrote a an library named Demo, and it has some headers (i.e. welcome.h for class Welcome, etc) for the library users.

    What I want?

    when installed by cmake install, all headers keep the original case(all lower case) filename.
    but I want get something like the QtCore. that is to say, the Demo library should be installed with a file tree like the following(which is the structure for qt internal modules like core, qml, widgets, etc.):

    ├── include
    │   ├── Demo
    │   │   ├──1.0.0
    │   │   │   └── Demo
    │   │   │       └── private
    │   │   │           ├── welcome_p.h
    │   │   │           ├── demo-config_p.h
    │   │   ├──Welcome
    │   │   ├──welcome.h
    │   │   ├──DemoVersion
    │   │   └──demoversion.h
    ├── lib
    │   ├── cmake
    │   │   ├── Demo
    │   │   │   ├── DemoConfig.cmake
    │   │   │   └── ...
    │   ├── libWelcome.so.1.0.0
    │   ├── ...
    │   ├── pkgconfig
    │   │   ├── DemoWelcome.pc
    │   │   └── ...
    │   ├── DemoWelcome.debug
    │   └── ...
    ├── metatypes
    │   ├── demo_debug_metatypes.json
    │   └── ...
    ├── mkspecs
    │   └── modules
    │       ├── qt_lib_welcome.pri
    │       └── ...
    ├── modules
    │   ├── Welcome.json
    │   └── ...
    └── sbom
        └── demo-1.0.0.spdx
    

    All in a word, how to make the library users use Demo like the way they use QtCore, for example:

    • In .cpp/.h file
    #include <Demo/Welcome>
    // or
    #include <Welcome>
    
    // BUT NOT LIKE THIS:
    #include <demo/welcome.h>
    
    • In CMakeLists.txt
    find_package(Demo 1.0.0)
    target_link_library(myapp Demo::Welcome)
    

    Tried solutions

    I have tried qt_internal_project_setup() / qt_internal_add_module(), but it requires the project's major version must be same to Qt's major version, and it does not generate camel case wrappers for header files!

    So, the question is:

    1. I do not want to write any camel cased header wrappers manually, it should be auto generated, and how?
    2. Or, is it possible to make my own library with the experiences same to the QtCore for the end users?
    C 1 Reply Last reply
    0
    • S Sauntor

      Environment

      • CMake
      • Ubuntu 24.04
      • Qt 6.8.1/Online Installer

      Case

      I have wrote a an library named Demo, and it has some headers (i.e. welcome.h for class Welcome, etc) for the library users.

      What I want?

      when installed by cmake install, all headers keep the original case(all lower case) filename.
      but I want get something like the QtCore. that is to say, the Demo library should be installed with a file tree like the following(which is the structure for qt internal modules like core, qml, widgets, etc.):

      ├── include
      │   ├── Demo
      │   │   ├──1.0.0
      │   │   │   └── Demo
      │   │   │       └── private
      │   │   │           ├── welcome_p.h
      │   │   │           ├── demo-config_p.h
      │   │   ├──Welcome
      │   │   ├──welcome.h
      │   │   ├──DemoVersion
      │   │   └──demoversion.h
      ├── lib
      │   ├── cmake
      │   │   ├── Demo
      │   │   │   ├── DemoConfig.cmake
      │   │   │   └── ...
      │   ├── libWelcome.so.1.0.0
      │   ├── ...
      │   ├── pkgconfig
      │   │   ├── DemoWelcome.pc
      │   │   └── ...
      │   ├── DemoWelcome.debug
      │   └── ...
      ├── metatypes
      │   ├── demo_debug_metatypes.json
      │   └── ...
      ├── mkspecs
      │   └── modules
      │       ├── qt_lib_welcome.pri
      │       └── ...
      ├── modules
      │   ├── Welcome.json
      │   └── ...
      └── sbom
          └── demo-1.0.0.spdx
      

      All in a word, how to make the library users use Demo like the way they use QtCore, for example:

      • In .cpp/.h file
      #include <Demo/Welcome>
      // or
      #include <Welcome>
      
      // BUT NOT LIKE THIS:
      #include <demo/welcome.h>
      
      • In CMakeLists.txt
      find_package(Demo 1.0.0)
      target_link_library(myapp Demo::Welcome)
      

      Tried solutions

      I have tried qt_internal_project_setup() / qt_internal_add_module(), but it requires the project's major version must be same to Qt's major version, and it does not generate camel case wrappers for header files!

      So, the question is:

      1. I do not want to write any camel cased header wrappers manually, it should be auto generated, and how?
      2. Or, is it possible to make my own library with the experiences same to the QtCore for the end users?
      C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      @Sauntor said in How to make a library with the installed layout looks like Qt's internal modules (a.k. QtCore, QtQml, ect.)?:

      All in a word, how to make the library users use Demo like the way they use QtCore, for example:

      You cannot control how the users use the headers provided but you can give then the option of "clean" header names like <QWidget> the same way that Qt does it. The deployed headers files are:

      - include
        - QtWidgets (directory)
          - QtWidgets (file)
          - QWidget (file)
          - qwidget.h (file)
      

      The file "QWidget" simply contains:

      #include "qwidget.h"
      

      The file QtWidgets similarly includes all the headers for the entire module.

      The qmake or cmake setup ensures that the include/QtWidget folder is added to the include path when the widget module is invoked (e.g. QT += widgets). The include folder is also present. So, the user can specify:

      // found via the top level include path
      #include <QtWidgets/QWidget>
      #include <QtWidgets/qwidget.h>
      // found via the QtWidgets include path
      #include <QtWidgets>
      #include <QWidget>
      #include <qwidget.h>
      

      To do this for your library you need to deploy at least the "clean" files.

      I do not want to write any camel cased header wrappers manually, it should be auto generated, and how?

      You only need to do this once and check it in to your source control. It's probably faster than trying to automate. As for how you could automate this; there's no magic bullet here.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved