Cross-compiling with ninja multi-config

Hi All,

I managed to cross compile with the ccrx v3.06 using ninja and cmake v4.0.2.

I would like to go multi-config BUT a define (CMAKE_INTDIR) is added under the hood.
The problem is that the ccrx accepts defines as -define=NAME=VALUE not -DNAME=VALUE.

I had a look at the cmake source code and I can see that in file cmNinjaTargetGenerator.cxx,
at line 311 there is the following code:

// Seriously??
  if (this->GetGlobalGenerator()->IsMultiConfig()) {
    defines.insert(cmStrCat("CMAKE_INTDIR=\"", config, '"'));
  }

The define is hard coded and pushed to the impl-<CONFIG>.ninja file in the DEFINES = line.
From cmake, I tried with remove_definitions("-DCMAKE_INTDIR=\"Debug\"") with no success.

I had a look at the cmake debugger, but I could not find anything related to CMAKE_INTDIR.

My question is: what should I do?

I considered compiling cmake by myself but I am not sure it is worth.

Thank you in advance

That line is correct, that is how to add a global define to the cflags of a generator.

The problem is it’s being serialized incorrectly, ie we’re not settings the CMAKE_CXX_DEFINE_FLAG correctly for ccrx and thus it’s being prefixed with -D instead of -define. I think this is just a straight up bug in our support for Renesas but I don’t have a Renesas compiler to test it out.

Modules/Compiler/Renesas.cmake does try to set this correctly:

macro(__compiler_renesas lang)

  if(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID STREQUAL "RX")
# CC-RX
    # Pass directly include and define flag to the assembler.
    if ("${lang}" STREQUAL "ASM")
      set(_ASM_PREFIX "-asmopt=")
    endif()
    set(CMAKE_INCLUDE_FLAG_${lang} "${_ASM_PREFIX}-include=")
    set(CMAKE_${lang}_DEFINE_FLAG "${_ASM_PREFIX}-define=")

So something else is going on here. Do any compile-definitions work correctly in your setup?

1 Like

set(CMAKE_${lang}_DEFINE_FLAG "-define=") was exactly what I was looking for (indeed, compile-definitions were not set properly)!

Also, Modules/Compiler/Renesas.cmake has been added in cmake 4.1.0-rc1, whilst I am on cmake 4.0.2.

Now, when using Ninja Multi-Config, CMAKE_INTDIR is added properly with
-define=CMAKE_INTDIR=\"Release\" and it works.

I will upgrade to cmake 4.1.0 as soon as it will be released.

Thanks a lot for your support.