Hi,
I would like to have a folder inside my Classes folder(i.e a submodule). I would like to make a CMakeLists.txt file in that submodule folder that will be used to add if any new files is added in that. And using that folder like a library in the main CMakeLists.txt.
As above, I need to use that submodule folder as a library or something in the main CMakeLists.txt, so that I dont have to add the files inside the submodule in the main CMakeLists.txt. Could you say me how to make a CMakeLists.txt file for the above case?
I have a button class which is made for my style extending ui::button and some other common classes which I ll be using in all of my projects. I wish to make them as a submodule and using them for different projects. For that I m not well sure how I could configure my cmakelists.txt file inside my submodule and compile it as a shared object file and link it to the main project. Creating a submodule and adding the files in main CMakeLists will work, but I don’t want that. I wish to do all the build in submodule itself and use it. Just like cocos2d folder inside the project. But here my submodule needs to use classes inside cocos2d folder as well. So how to write CMakeLists.txt file for my submodule keeping all these factors. Is it possible?
You need to refactor your code. If you have something you need to put into a sub-module, then it shouldn’t have dependencies to code in your main app. Why don’t you move those dependencies into their own library as well?
You don’t really need to use a separate library for all of this either. You can just have a separate folder, which you can put in Classes if you want, as you originally mentioned above, and just copy it between your projects. It can have it’s own CMakeLists.txt, but no need to build a separate library from it. For example, the CMakeLists.txt would look something like this:
This does not solve the problem of the sub-module dependencies, so again, if a sub-module has dependencies on other code in Classes, then you really need to re-think the structure of your code.