0

Ok, so I have an existing project that compiles code, creates executables, and everything works great (on both Linux and Windows).

Now... I want to add another executable to my project, but the difference is, I want to cross-compile that executable. We are using Clang for everything, so we can pass a --target as a compiler flag for this new target, and it works (i.e., the code compiles for the target that I want).

The problem is with the linker. When I am on Windows, things get ugly because the target is x86_64-elf, and so obviously link.exe cannot use that. If we pass in -fuse-ld=lld, it is ignored as CMake already sets this to link.exe. CMake is also adding a bunch of Windows specific junk like libraries, and there doesn't seem to be a way to turn this stuff off.

Is there a way to add a target and give it s specific toolchain, or something like that with CMake without having to use ExternalProject_Add to support cross compiling a specific target. This is how we did it before, and it works great, but there are a lot of disadvantages to this approach. Figured I would ask.

Rian Quinn
  • 1,766
  • 12
  • 22

1 Answers1

0

You should consider using ninja as a build system in conjunction with cmake and clang. This might help.

JSalaun
  • 41
  • 2