I am writing a QML plugin/module for custom GUI controls for a big project at work. We use CMake for project building. The main structure of the QML module (after compilation) must be like this:
MyModule
myplugin.dll
control1.qml
control2.qml
…
The most important thing is that all qml files and the shared library plugin (myplugin.dll in the example) MUST be placed in the directory with EXACTLRY the name of the module (MyModule in the example). As a post build step all qml files are copied into this binary output directory.
And here is the problem: compiled binary files (myplugin.dll in the example) are placed in the directories Debug
, Release
, and so on, inside the output directory. Because of that the result looks like: MyModule/Debug/myplugin.dll
- and module does not work. I’ve tried manipulating RUNTIME_OUTPUT_DIRECTORY_DEBUG
, RUNTIME_OUTPUT_DIRECTORY_RELEASE
and all that messy zoo, but… it is not an option, because as far as I know build-config types can be custom, so I cannot foresee all possible RUNTIME_OUTPUT_DIRECTORY_
variants and specify them in advance.
Is there any normal way to structure my output directory inside those Debug
, Release
, ConfigIDontKnowAboutYet
? For example, instead of making it like this: MyModule/Debug/myplugin.dll
- turning it into this: MyModule/Debug/MyModule/myplugin.dll
– because the last part of the path must be exactly .../MyModule/myplugin.dll
, otherwise it won’t work. If there is no such way, how do people deal with it?
Another important thing is that this module is supposed to be used by a bigger project by add_subdirectory()
. And here all that Debug
– Release
- MyOwnConfig
mess makes it all even much harder.
The only more-or-less solution found so far was to install()
resulting compiled and qml files of MyModule into binary output directory of the bigger project that contains MyModule as a dependency. However, there is another problem. It turns out in this case I have to install MyModule twice: one time into binary output directory of the bigger project in order to build / test / run it, and the second time when I install the bigger project itself.
I would very much appreciate any suggestions. Also, if someone has a quite big project that uses CMake, C++ and depends on QML modules I would be really grateful if they provided a link to have a look at it. Thanks.