Qmake single project, multiple toolchains
-
I have searched for a solution to my issue, and haven't been able to find it. I wish to be able to have qmake build a project, that contains subprojects with different toolchains.
I have a subdir project with projects that need to be compiled with the host toolchain, and some with a target toolchain.
MyProject
- HostTools
- TargetApp
In my specific case, HostTools needs to be able to be built using the local default compiler (g++, VisualStudio, etc) and the TargetApp needs to be build using the cross-compiling toolchain, which may be an entirely different architecture. For my scenario I actually need HostTools compiled prior to TargetApp as well, as it uses the target output as a tool to build the TargetApp.
Currently my solution is to run qmake on HostTools and TargetApp separately, each with their own qmake -spec argument. I would like to be able to manage the build using a single centralized project, and have each subproject reference a different qmakepec, but I don't see a way to easily do this.
Strategy 1:
Have a configure script run prior to running make, which checks what local platform you are on and calls each project with the appropriate -spec argument. This works, but is clunky, and also the projects don't show up properly under QtCreator, and cannot be cleaned easily. Also I now am managing a set of cross platform build scripts, which was a big reason to use qmake in the first place.Strategy 2:
Custom mkspec with references to both toolchains, local and remote, and local would point to the default local mkspec. I could then add some configuration value to each .pro file to tell it which toolchain to use, local or remote.Strategy 3:
Each subdirectory project would have a project cache file which I could configure once with toolchain info, like qtcreator has the .pro.user files. This would appear to be an option but not sure it works with subdirectories. Also it needs to be a solution that can be shared in version control, so it works easily with minimal developer configuration and could build easily on a CI server like Jenkins.Strategy 4:
Define a QMAKE_CUSTOM_COMPILER for the host toolchain. This seems like an overreach for what this is designed to do, basically reinvent the concept of mkspecs essentially.Anyone have any suggestions? I figure I am not the first person to try to do this, but I can't find an obvious solution to this issue. I am hoping there is a way to do Strategy 2 or 3 that I am not aware of.