ExternalProject and CMAKE_TOOLCHAIN_FILE


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).

@craig.scott is right. In my case I have much more variable to pass.
For the moment I pass manually each one but I don’t think this is a reliable way.

I just would like to know if we could find or even add an option for externalProject function to keep the same build environement than main one.

It may be reasonable to make such a change to ExternalProject, but unfortunately I don’t have the bandwidth to explore that.

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.