Currently, when CMake is cross compiling, it sets CMAKE_CROSS_COMPILING
to TRUE
. This also ends up meaning we can't compile any tools for code generation or otherwise when cross compiling. This is a huge limitation. However, there is a workaround and we can wrap it up into a special add_tool()
command.
This command will perform the following steps when CMAKE_CROSS_COMPILING
is ON
- Get the current list of enabled languages.
- For each language we
unset()
certain variables in the current function scope.
set()
the current CMAKE_SYSTEM_NAME
into a temporary variable
set()
the CMAKE_HOST_SYSTEM_NAME
to CMAKE_SYSTEM_NAME
set(CMAKE_PLATFORM_INFO_DIR)
to some predetermined directory
include(CMakeDetermine<LANG>Compiler)
- `include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCompiler.cmake)
set()
host versions of variables
- Set variables onto a
dict()
and save to disk with some sort of hash
- Call
try_compile(PROJECT)
with flags that are stored in said dict()
(We cannot use generator expressions 😞). The project can either be the current one, or a separate one altogether.
- Call
add_executable(name IMPORTED)
and set the path to the given target.
The above is just the tip of the iceberg. There are many MANY things that need to be taken into account, such as, but not limited to:
- FetchContent locations
- System Dependencies
- Variables set by toolchain files
This is going to be a big feature, but it is EXTREMELY useful. That said, it's low priority until everything else is stable.
✨ enhancement ✨ modules 🔮 tools 🛠️