# Cross-compiling with ninja multi-config

**URL:** https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291
**Category:** Usage
**Tags:** gen:ninja
**Created:** [June 27, 2025, 12:15pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291 "2025-06-27T12:15:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![galax](https://discourse.cmake.org/user_avatar/discourse.cmake.org/galax/32/5636_2.png) [@galax](https://discourse.cmake.org/u/galax)
#### Post date: [June 27, 2025, 12:15pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291/1 "2025-06-27T12:15:32Z")

</div>

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:

```auto
// 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

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [June 28, 2025, 3:55pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291/2 "2025-06-28T15:55:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [June 28, 2025, 3:57pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291/3 "2025-06-28T15:57:32Z")

</div>

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

```cmake
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?

---

<div class="post-metadata">

### Author: ![galax](https://discourse.cmake.org/user_avatar/discourse.cmake.org/galax/32/5636_2.png) [@galax](https://discourse.cmake.org/u/galax)
#### Post date: [June 30, 2025, 1:52pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291/4 "2025-06-30T13:52:34Z")

</div>

`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.
