The CMake "include" vs "add_subdirectory" with Qt. Which is better?
-
Hello all!
For now redeveloping application and moving it from QMake to CMake. Got currious about which is better to use when Qt Application developing with CMake using "includes" or using "add_subdirectory"? Read a lot about this topic:- https://stackoverflow.com/questions/48509911/cmake-add-subdirectory-vs-include
- https://cmake.org/pipermail/cmake/2007-November/017895.html
- https://stackoverflow.com/questions/49984011/cmake-include-vs-add-subdirectory-relative-header-file-path
- https://stackoverflow.com/questions/12761748/cmake-difference-between-include-directories-and-add-subdirectory
- https://stackoverflow.com/questions/42744315/cmake-with-subdirectories
But still not clear about it, especcially in case of using Qt. Got some troubles when attaching native languages in Qt project when using native in sub_directory project like sub-target (for example when using Swift with Qt for iOS) When Qt CMake created like all-in one and using only includes all is working perfectly with native languages. But include not always Ok with speed of building, using subtargets reducing this time and making whole project more maintainable.
What is the pros and cons of both of this ways in CMake in case of using it with Qt? Suggestions?
-
include() and add_subdirectory() are imo two completely different things. Esp. since include is searching for a cmake file in it's path whereas add_subdirectory() explcitly add the subdirectory() and use the CMakeLists.txt in there.
-
include() and add_subdirectory() are imo two completely different things. Esp. since include is searching for a cmake file in it's path whereas add_subdirectory() explcitly add the subdirectory() and use the CMakeLists.txt in there.
@Christian-Ehrlicher Thx for reply. Know it. But both of it might be used in project architecture for Qt. Just asking which aproach is better in case of Qt with CMake. Is there any thoghts about it?
-
@Christian-Ehrlicher Thx for reply. Know it. But both of it might be used in project architecture for Qt. Just asking which aproach is better in case of Qt with CMake. Is there any thoghts about it?
@bogong said in The CMake "include" vs "add_subdirectory" with Qt. Which is better?:
Just asking which aproach is better in case of Qt with CMake.
I already answered what's the difference so I don't understand the question... if you have a subdirectory to include, use add_subdirectory(), if you've a cmake module, use include(), doesn't matter if you compile Qt or not - Qt is just c++
-
@bogong said in The CMake "include" vs "add_subdirectory" with Qt. Which is better?:
Just asking which aproach is better in case of Qt with CMake.
I already answered what's the difference so I don't understand the question... if you have a subdirectory to include, use add_subdirectory(), if you've a cmake module, use include(), doesn't matter if you compile Qt or not - Qt is just c++
@Christian-Ehrlicher Thx. Issue closed.