[CMake] dependencies of cross compiliations

Miller Henry MillerHenry at JohnDeere.com
Fri Nov 9 09:55:53 EST 2018


There are two options. Each with pros and cons.

The first what you are doing now, except you use external project https://cmake.org/cmake/help/v3.12/module/ExternalProject.html to build the host tools instead of add_custom_command. It otherwise has all the cons you mention, but are they significant (this is a question that is different for each project)?  Going back to the manual build for host before the target isn't bad, though it is harder to teach.

The second is to use a package/dependency manager to setup your build environment with all tools. In this approach the host tools would be in a separate source control repository and the package manager will download the latest binaries. Conan.io comes to mind as a tool to do this, but there are at least a dozen others that you can choose from (or write your own if you have a year to spend) . This approach is much more complex, but these systems offer many other features that are often compelling.

I would recommend you spend some time researching the package/dependency manager tools available. It is likely that you (or your team) will look at some feature completely unrelated to your question and say "This is a good solution to our problem". At that point your question changes from "how do I best make cmake do this" to "how do I do this in my new package manager". If after a review nothing stands out, your approach is perfectly fine, the only question is it worth tweaking.

-----Original Message-----
From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Torsten Robitzki
Sent: Friday, November 9, 2018 3:04 AM
To: cmake at cmake.org
Subject: [CMake] dependencies of cross compiliations

Hi,
I hope this question was not asked before. I work in the embedded field and there it is usually to have at least two different build platforms. The Host platform, where unit tests are build (and where CMake is running) and an embedded Target platform, where targets are build with a cross compiler. Sometimes such a system comes with self-written tools that are build and run on the Host platform to build a target for the embedded Target platform (adding meta data to a binary to be used by a bootloader for example).

Usually I have two different build folders, one for the Host platform and one for the Target platform, using different calls to cmake to choose from a set of tools and targets. But when using this approach, it is necessary that the Host platform build ran before the Target platform build, so that tools that are required for the Target platform are build during the Host target build.

One solution I’ve came up with, is to build the required tools during the Target platform build, using an add_custom_target() to invoke the Target compiler directly. This works fine, as long as the tools are basically build just out of a couple of files. 

What would be the „CMake-Way“ to add the tools (that have to be build on the Target platform) as dependency to targets that have to be build for the Target (cross compile) platform?

Kind regards and thanks in advance,

Torsten
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list