1

I am developing an Ubuntu Phone application "QML app with C++ plugin (cmake)" but I have so many qml files so I want to separate them by functionality

ApplicationName

  • CMakeListes.txt
  • ..
  • app
    • CmakeListes.txt
    • ApplicationName.desktop.in
    • tests
    • mainComponents
      • sub directories of mainComponents
        • some files
      • some other files
    • ApplicationName.qml
  • po
    • CMakeListes.txt
  • ApplicationName.apparmor
  • manifest.json.in

but the "mainComponents" folder dose not appear in the project tree and after some searches I found that I must add CMakeListes.txt in every new folder and this:

add_subdirectory(folder_name)

instruction in the parent folder CMakeListes.txt file but I don't if there is more to add and I don't know how to create the CMakeListes.txt

thanks

1 Answer 1

3

You just need to learn the CMake language. It is the language of the CMakeListes.txt files that are all over the project.

This language specifies how to build the project. And this language is independent from the QtCreator IDE that we are using. So, you can do builds without QtCreator and create CMakeListes.txt manually where you wish.

Back to the problem:

You can use 'add_subdirectory' and write CMakeListes.txt for each subdirectory and append file names to QML_JS_FILES variable in each CMakeListes.txt.

But you can also do as the guys who develop core application do: for example in ubuntu-terminal-app (source code is on https://launchpad.net), they use a recursive include in app/CMakeListes.txt:

file(GLOB_RECURSE QML_JS_FILES *.qml *.js)

instead of non-recursive:

file(GLOB QML_JS_FILES *.qml *.js)

update: Yes, generally, GLOBs are not recommended, but they are already in the project templates to simulate some kind of 'automatic' behavior.

2
  • All of the content of the app directory is just 1 qml project so I think that this is "file(GLOB_RECURSE QML_JS_FILES *.qml *.js)" what I am looking for and it worked thank you so much Velkan.
    – leouss4dev
    Apr 3, 2015 at 22:03
  • 1
    Note that the CMake manual recommends against using GLOB for this purpose: "We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate." Apr 4, 2015 at 3:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .