# CMake RC Support (Ninja)?

**URL:** https://discourse.cmake.org/t/cmake-rc-support-ninja/2883
**Category:** Usage
**Tags:** os:windows, gen:ninja
**Created:** [March 3, 2021, 10:27pm UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883 "2021-03-03T22:27:26Z")
**Posts on this page:** 7
**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 3, 2021, 10:27pm UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/1 "2021-03-03T22:27:26Z")

</div>

I’m unable to compile a simple project Ninja. I’ve made a SSCCE to demonstrate the issue.

My command line is super basic:

```auto
 cmake -S . -B build -G "Ninja" -DCMAKE_MAKE_PROGRAM=D:\foobar\ninja.exe

```

Here are the files contents:

- This is the CMakeLists.txt

```auto
cmake_minimum_required(VERSION 3.20)

project(demo)

add_executable(demo)

target_sources(demo PRIVATE
    main.cpp
    demo.rc
)

```

- This is the RC file in question causing the havoc.

```auto
#include <winres.h>

// Little macro tricks this turn number defines into non-quoted strings
#define STRINGIZED_HELPER( a ) #a
#define STRINGIZED( a ) STRINGIZED_HELPER( a )

#define DEMO_VERSION_MAJOR 1
#define DEMO_VERSION_MINOR 2
#define DEMO_BRANCH_VERSION_LEVEL1 3
#define DEMO_BRANCH_VERSION_LEVEL2 4
#define DEMO_BRANCH "demo_shorty"

#define DEMO_VER_STR STRINGIZED(DEMO_VERSION_MAJOR) "," STRINGIZED(DEMO_VERSION_MINOR) "," STRINGIZED(DEMO_BRANCH_VERSION_LEVEL1) "," STRINGIZED(DEMO_BRANCH_VERSION_LEVEL2) "\0"
#define FILEVER DEMO_VERSION_MAJOR,DEMO_VERSION_MINOR,DEMO_BRANCH_VERSION_LEVEL1,DEMO_BRANCH_VERSION_LEVEL2
#define PRODUCTVER DEMO_VERSION_MAJOR,DEMO_VERSION_MINOR,DEMO_BRANCH_VERSION_LEVEL1,DEMO_BRANCH_VERSION_LEVEL2
#define VS_PACKAGE_FILEVER DEMO_VERSION_MAJOR,DEMO_VERSION_MINOR,DEMO_BRANCH_VERSION_LEVEL1,DEMO_BRANCH_VERSION_LEVEL2
#define VS_PACKAGE_PRODUCTVER DEMO_VERSION_MAJOR,DEMO_VERSION_MINOR,DEMO_BRANCH_VERSION_LEVEL1,DEMO_BRANCH_VERSION_LEVEL2
#define STRFILEVER DEMO_VER_STR
#define STRPRODUCTVER DEMO_VER_STR
#define VS_PACKAGE_STRFILEVER DEMO_VER_STR
#define VS_PACKAGE_STRPRODUCTVER DEMO_VER_STR
#define STRCOMPANYNAME L"Foobar Inc.\0"
#define STRCOPYRIGHT L"(C) 2015-2021 Foobar Inc. For internal use only.\0"
#define STRFILEDESCRIPTION L"DEMO " DEMO_BRANCH " ver " DEMO_VER_STR "\0"
#define STRPRODUCTNAME L"DEMO\0"
#define VS_PACKAGE_STRPRODUCTNAME L"DEMO\0"

VS_VERSION_INFO VERSIONINFO
 FILEVERSION FILEVER
 FILEFLAGSMASK 0x3fL
 FILEFLAGS 0x0L
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904B0"
        BEGIN
            VALUE "CompanyName", STRCOMPANYNAME
            VALUE "FileDescription", STRFILEDESCRIPTION
            VALUE "FileVersion", DEMO_VER_STR
            VALUE "LegalCopyright", STRCOPYRIGHT
            VALUE "LegalTrademarks", "\0"
            VALUE "ProductName", STRPRODUCTNAME
            VALUE "ProductVersion", DEMO_BRANCH
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

```

- This is main.cpp

```cpp
#include <stdio.h>

int main(int argc, char** argv) { return 0; }

```

And I run this in a VS 2019 command prompt yet it fails:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/6/69d47992b927ac125f0db7777d132347e0172307.png)

It seems to be unable to find the appropriate environment for the RC/MT:  
 ![image](https://discourse.cmake.org/uploads/default/original/2X/3/30a63459c4bef14f61e00203c2a2089fc5f3d16b.png)

---

<div class="post-metadata">

### Author: ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)
#### Post date: [March 4, 2021, 1:46am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/2 "2021-03-04T01:46:09Z")

</div>

Worked fine for me:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/1/117a0ab05a7144942338160b1c71366c1f0b395f.png)

You might have some scripts or some funny business messing up the environment path though. I’d double check that.

---

<div class="post-metadata">

### Author: ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)
#### Post date: [March 4, 2021, 1:53am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/3 "2021-03-04T01:53:50Z")

</div>

Here is a sample of what my cmake cache looked like:  
[CMakeCache.txt](https://discourse.cmake.org/uploads/short-url/idrPTnCogXHmBHK7lMLVndVWqnp.txt) (14.2 KB)

---

<div class="post-metadata">

### Author: ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)
#### Post date: [March 4, 2021, 2:49am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/4 "2021-03-04T02:49:11Z")

</div>

I even got it working with clang

```auto
C:\git\rc_compiler_issue>cmake -S . -B build -G "Ninja" -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
-- The C compiler identification is Clang 11.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 11.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/git/rc_compiler_issue/build

C:\git\rc_compiler_issue>cmake --build build
[1/3] Building RC object CMakeFiles/demo.dir/demo.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.

[3/3] Linking CXX executable demo.exe

C:\git\rc_compiler_issue>

```

---

<div class="post-metadata">

### Author: ![anon45792294](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@anon45792294](https://discourse.cmake.org/u/anon45792294)
#### Post date: [March 4, 2021, 2:50am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/5 "2021-03-04T02:50:16Z")

</div>

Here is what the cache looks like for the clang path:  
[CMakeCache.txt](https://discourse.cmake.org/uploads/short-url/AmuLqJ5NIYoz4CnvqoSMT5n2uqM.txt) (15.5 KB)

---

<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 4, 2021, 1:51pm UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/6 "2021-03-04T13:51:04Z")

</div>

Usually this means that you forgot/missed the SDK installation in the Visual Studio installer. The compiler components are just the C/C++ compilers. The `rc` and `mt` tools come with the SDK (the `binutils` analogous bit).

---

<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 5, 2021, 12:35am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883/7 "2021-03-05T00:35:58Z")

</div>

It was a combination of not having enough stuff. As you mentioned @ben.boeckel

And due to work reasons having my path cluttered in an awkward way. As was mentioned by @anon45792294
