Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi there,

I've gotten cross-compilation working in that I'm now able to build a binary executable for the raspberry pi.

How would I go about adding support to still build for the host processor (e.g. Linux running on amd64)?

Does anyone have experience on how to go about doing this?

You must be logged in to vote

@emptor8 I didn't understand your question, can you elaborate with an example? Are you asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?

Replies: 1 comment · 4 replies

Comment options

@emptor8 I didn't understand your question, can you elaborate with an example? Are you asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?

You must be logged in to vote
4 replies
@emptor8
Comment options

@emptor8 I didn't understand your question, can you elaborate with an example? Are asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?

Yeah, exactly -- I'm wondering if you know a good way to cross compile for raspberry pi, and compile normally for amd64 simultaneously. The amd64 compilation would be for running host-based unit tests.

@abhiTronix
Comment options

@emptor8 That's actually quite simple. All you need is seperate GCC toolchain and "make" tool like the CMake(can do both cross and native compiling) with seperate .cmake file for every target OS environment. You can find PI.cmake file used for raspbian OS cross-compiling in our wiki docs, and for other platforms make your own. Make sure to use seperate build folders as necessary.

Also, if you're running compilation parallelly make sure your available processing power and RAM is capable of doing so.

But I would also recommend you to have a continuous integration server somewhere with one client for every OS target and architecture rather than doing this one machine. This will ease the pain of incompatible changes that you make in one OS. And you will also be able to ensure installation by package manager or installer

@emptor8
Comment options

Thanks, with your help I I've gotten close to what I want to do. I'm running into one issue - is there a way to conditionally select which "subdirectories" are included in each of the .cmake files? Right now my CMakeLists.txt file lists all the subdirectories, but what if I don't want to build certain directories in the Raspberry Pi build?

For example, let's say I've got a src and a test directory. For my host.cmake build, I want to build both the src and test directories. However, for my rpi.cmake build, I only want to build the src folder.

Is there a good way to achieve this?

My top level CMakeLists.txt contains add_subdirectory(src) and add_subdirectory(test). I want a way to be able to have host.cmake use both directories, but rpi.cmake only use the src directory.

@emptor8
Comment options

Okay never mind - I figured out how to do this using an if() / endif() in the CMakeLists.txt, and using option() in the host.cmake file.

Answer selected by emptor8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.