I’m using CMake to build my OpenSource project, for home automation : Yadoms
Our software supports many platforms (Windows, linux, mac) and cross compilation (RaspberryPI, Synology NAS,…)
We are using “ExternalProjects” to build our dependencies.
My problem is our that our external project, is also a cmake project.
In case of cross compiling our software, we use a command line argument to specify CMAKE_TOOLCHAIN_FILE But ExternalProject don’t get the same build environment than our main software.
Is there a way for my “cmake based externalprojects” to be built with same environment than main cmake project ?
Sadly, there’s often much more to pass through if you want to preserve things from the main project through to the subproject. See lines 721-806 of this example from a change I’ve been working on recently for the Qt project (look specifically for things relating to vars_to_pass_if_defined and var_defs).
If i understand correctly, your tool chain is applied to the entire project. In this case you don’t need to use external project. You could have a single CMake project which handles different platforms and specify the tool chain for it.