# Setting CMAKE\_\<LANG\>\_ARCHITECTURE\_ID/CMAKE\_CL\_SHOWINCLUDES\_PREFIX to get RC files working?

**URL:** https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920
**Category:** Usage
**Tags:** comp:msvc, os:windows, gen:ninja
**Created:** [March 8, 2021, 6:53pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920 "2021-03-08T18:53:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 8, 2021, 6:53pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/1 "2021-03-08T18:53:16Z")

</div>

We have a custom MSVC toolchain. However, we were getting an issue related to RC files. That only manifested on Ninja dirty builds.

```auto
        # Here is the bug will manifest itself:
        # "ninja: error: FindFirstFileExA(note: including file: d:/foobar/ms_sdk/n20246/10/include/10.0.20246.0/shared): The filename, directory name, or volume label syntax is incorrect."

```

An engineer at our company was able to workaround this bug by putting the following code in our custom toolchain:

```auto
        # This is neccessary to ensure RC files compile with our custom toolchain
        # Otherwise dirty builds will break. This code basically patches a cmake bug.
        if (CMAKE_GENERATOR MATCHES "Ninja")
            # Compiling RC files needs to set this. The Ninja generator calls cmcldeps.exe to extract dependencies for RC
            # files. But it configurates DepType to "gcc" so cmake cannot filter show includes prefix and the dependencies
            # are stored in .ninja_deps with the prefix and cause next run of ninja to fail. The DepType cannot be forced
            # to "msvc" otherwise the dependency changes won't trigger recompilation of RC files.
            # The workaround is to set CMAKE_CL_SHOWINCLUDES_PREFIX to the exact English string "Note: including file: ".
            # function CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX may be used if any locale issue occurs.
            set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: " CACHE INTERNAL "AMD WORKAROUND")

            # The Ninja generator relies on the following variables to determine MSVC style PDB names. But these variables
            # stored in cmake are only initialized to "" when it is first time run on a project before CMake${lang}Compiler
            # .cmake are generated. The next run doesn't initilazed them because CMake${lang}Compiler.cmake are there. So
            # they are null and SetMsvcTargetPdbVariable() returns false so ".dbg" suffix is used for PDBs.
            # The workaround is to set them to either x64 or x86 (actually "" is enough).
            #
            # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.html?highlight=architecture_id
            set(CMAKE_CXX_ARCHITECTURE_ID "x64" CACHE INTERNAL "AMD WORKAROUND")
            set(CMAKE_C_ARCHITECTURE_ID "x64" CACHE INTERNAL "AMD WORKAROUND")
        endif()

```

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 8, 2021, 6:55pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/2 "2021-03-08T18:55:14Z")

</div>

This issue with resource files only shows up with our custom toolchains using Ninja.

It works fine when we aren’t using a custom toolchain. And this bug only manifests itself on Ninja.

I’d like to not have this code in the future because it requires deeper knowledge of CMake then is desirable for us.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 8, 2021, 7:19pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/3 "2021-03-08T19:19:03Z")

</div>

I think an issue with this information would be warranted. I don’t know where the ultimate fix would be, but I’d guess that the custom toolchains are either missing some detail (in which case docs could be improved) or are missing hooks to set these kinds of things (in which case docs and code could be improved).

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 8, 2021, 7:49pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/4 "2021-03-08T19:49:08Z")

</div>

How can I help you all get the information you need?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 8, 2021, 10:00pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/5 "2021-03-08T22:00:12Z")

</div>

The toolchain file you’re using, platform details, and the error/workaround should be sufficient. You can submit it [here](https://gitlab.kitware.com/cmake/cmake/-/issues).

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 8, 2021, 11:55pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/6 "2021-03-08T23:55:25Z")

</div>

I’ve create an issue and provided the toolchain.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 9, 2021, 3:08pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/7 "2021-03-09T15:08:57Z")

</div>

Thanks. For reference, the issue is [here](https://gitlab.kitware.com/cmake/cmake/-/issues/21905). I see that it is marked as confidential. If there isn’t any non-public information, please make it public so others can see it and add input (if they’ve seen the same problem). I’ll leave that up to you in case something is sensitive.

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 9, 2021, 3:52pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/8 "2021-03-09T15:52:06Z")

</div>

I triple checked everything. For the third time. I did a good job sanitizing it. I just don’t know how to unmark it as confidential.

---

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [March 11, 2021, 5:51pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920/9 "2021-03-11T17:51:52Z")

</div>

Thanks to opening up the issue I was able to fix the problem for the Ninja builds.

I was specifying too much information in the toolchain like @brad.king said.

“At least CMAKE\_LANG\_COMPILER\_ID, CMAKE\_LANG\_COMPILER\_VERSION, CMAKE\_LANG\_ARCHITECTURE\_ID, and CMAKE\_LANG\_STANDARD\_COMPUTED\_DEFAULT should all be computed by CMake automatically. By setting them in the toolchain file you may be messing with CMake’s internal logic and break other things.”

He was exactly right. Specifying too much stuff was causing problems leading me to specify even more stuff.

Currently here is all I need to specify for my ninja toolchain:

- CMAKE\_SYSTEM\_NAME (If host doesn’t match target)
- CMAKE\_SYSTEM\_VERSION
- CMAKE\_SYSTEM\_PROCESSOR
- CMAKE\_C\_COMPILER
- CMAKE\_CXX\_COMPILER
- CMAKE\_RC\_COMPILER
- CMAKE\_MT
- CMAKE\_\*\_LINKER\_FLAGS\_INIT
  - EXE SHARED STATIC MODULE

- CMAKE\_LANG\_STANDARD\_INCLUDE\_DIRECTORIES
