build-cpp/cmkr

Abiity to build a project with two different architectures

realoriginal opened this issue · 3 comments

Bit of an odd request, unless it already exists - I've been unable to achieve it. I attempted to essentially have singular cmkr.toml file that builds an x86, and x64 variation of the same code base using the following TOML:

[cmake]
version = "3.19"
cmkr-include = "cmake/cmkr.cmake"

[project]
name = "reaper"

[target.reaper-x64]
type = "executable"
sources = [ "src/*.c" ]
include-before = [ "cmake/toolchain-x64.cmake" ]

[target.reaper-x86]
type = "executable"
sources = [ "src/*.c" ]
include-before = [ "cmake/toolchain-x86.cmake" ]

With the toolchain files containing the respective overwrites for the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER variables. However, understandably, the include-before of the last target ( x86 ) overwrites the CMAKE_C_COMPILER for the x64 build. Would it be plausible to achieve this - Or is it generally recommended to instead build each part separately by overwriting it during the build time -DCMAKE_C_COMPILER={CROSS_PREFIX}-clang etc

The intention is that so I may be run cmkr build that builds the [project] as two different architectures/compilers in one singular build.

Went with a somewhat moronic alternative of using the compile flags feature to achieve it, forcing the injection of the flag I needed.

Just FYI, this is very much not recommended with CMake.