A lot of includes notification appears in building with "NMake Makefiles" generator and VS2019 in Japanese locale

When I try to build C applications with “NMake Makefiles” generator and VS2019 in Japanese locale, a lot of includes notification appears on the command prompt screen and so I tend to miss important messages.
Here is a reproducer:

type CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.12)
project(hello_world)
add_executable(app main.c)

type main.c:
 #include <stdio.h>
 int main() {
    printf("Hello World");
    return 0;
 }

The output:
C:\Users\t34ma\Documents\Work\VS2019-include-notices\hello_world\cmbuild>cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 19.29.30136.0
-- The CXX compiler identification is MSVC 19.29.30136.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.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 (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/t34ma/Documents/Work/VS2019-include-notices/hello_world/cmbuild

C:\Users\t34ma\Documents\Work\VS2019-include-notices\hello_world\cmbuild>nmake

Microsoft(R) Program Maintenance Utility Version 14.29.30136.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 50%] Building C object CMakeFiles/app.dir/main.c.obj
main.c
・<・ インクルード ファイル:  C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h
・<・ インクルード ファイル:    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h
・<・ インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\sal.h
・<・ インクルード ファイル:      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\concurrencysal.h
・<・ インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vadefs.h
・<・ インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_wstdio.h
・<・ インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_stdio_config.h
[100%] Linking C executable app.exe
[100%] Built target app

As far as I investigated:

  1. The building process itself is successfully done.
  2. English version of VS2019 outputs no includes notification - it works fine.
  3. When using /showIncludes option, the Japanese message is “メモ: インクルード ファイル:”.
  4. I installed Visual Studio Community 16.11.4. Yesterday, I tried to update to latest one - 16.11.5. But the problem still exists.

So, in the interface between CMake and VS2019(CL.exe in Japanese locale), something is wrong and garbage character might be induced.
Is this CMake problem or should I ask VS2019 people?

Regards,
Tetsuya Mishima

I suspect a bad detection of the ShowIncludes prefix.

What is the content of variable CMAKE_CXX_CL_SHOWINCLUDES_PREFIX?

Hi marc.chevrier, thank you for your quick reply.

OK, I added the last line to the CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.12)
project(hello_world)
add_executable(app main.c)
message(${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX})

Then, I got:

cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 19.29.30136.0
...(skipped)
-- Detecting CXX compile features
-- Detecting CXX compile features - done
メモ: インクルード ファイル:
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/t34ma/Documents/Work/VS2019-include-notices/hello_world/cmbuild

So, it’s properly detected:

The number of includes notifications are varied every execution.
So I guess it’s an erroneous behavior of CMake/VS2019.

Regards, Tetsuya Mishima

This is clearly a CMake bug in the filtering stage of compiler output.

Can you create an issue for this and include your description of the problem?

Thank you.

Thank you for your advice.
I will create an issue and report the problem there later.
Regards,
Tetsuya Mishima

After a first inspection of CMake code involved in this feature, I didn’t see any obvious problem. So, I am no longer sure where the problem comes from…

@tmishima can you do some more investigation:

  1. If your VS version is older than 16.8.5, can you check with a newer release?
  2. Can you do the same test with Ninja generator? Do you have any spurious message?
  3. Do a simple test using directly nmake (so without evolving CMake) of compilation with option/showIncludes. Any corrupted messages?

Thank you for your help.

Hi Marc Chevrier, Thank you for you reply.

Answer to your request for further invesitigations:

  1. Yes, my VS2019 is now updated to the latest - 16.11.5, but the problem still exists.
  2. Sorry, I don’t use Ninja - I can not check the behavior on the Ninja-IDE.
  3. Regarding "without evolving CMake" , I don’t see any corrupted message as follows:
cl /showIncludes  main.c
Microsoft(R) C/C++ Optimizing Compiler Version 19.29.30136 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
メモ: インクルード ファイル:  C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h
メモ: インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt.h
メモ: インクルード ファイル:    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h
メモ: インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\sal.h
メモ: インクルード ファイル:      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\concurrencysal.h
メモ: インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vadefs.h
メモ: インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_wstdio.h
メモ: インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_stdio_config.h
Microsoft (R) Incremental Linker Version 14.29.30136.0
Copyright (C) Microsoft Corporation.  All rights reserved.

By the way, I have already created a issue on the cmake-gitlab as you suggested.

Regards,
Tetsuya Mishima

For 2., just install executable ninja and use CMake generator Ninja. You can install anywhere and specify variable CMAKE_MAKE_PROGRAM on the CMake command line to locate ninja tool:

cmake -DCMAKE_MAKE_PROGRAM=/path/to/ninja -G Ninja <src>

For 3., I mean using nmake to do the compilation. Example of simple makefile:

all: main

main: main.c
<tab>cl /showIncludes main.c

And run namake:

prompt> nmake /F makefile

Thanks. I tried to do it quickly.

About 2, I didn’t see any spurious message:

C:\Users\t34ma\Documents\Work\hello_world\cmbuild>cmake -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_C_COMPILER=cl.exe -DCMAKE_MAKE_PROGRAM=C:/Users/t34ma/Documents/Work/ninja.exe -G Ninja ..
-- The C compiler identification is MSVC 19.29.30136.0
-- The CXX compiler identification is MSVC 19.29.30136.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.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 (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/t34ma/Documents/Work/hello_world/cmbuild

C:\Users\t34ma\Documents\Work\hello_world\cmbuild>..\..\ninja.exe
[2/2] Linking C executable app.exe

C:\Users\t34ma\Documents\Work\hello_world\cmbuild>app
Hello World

About 3, also no corrupted messages:

C:\Users\t34ma\Documents\Work>type Makefile
all: main

main: main.c
        cl /showIncludes main.c

C:\Users\t34ma\Documents\Work>nmake -f Makefile

Microsoft(R) Program Maintenance Utility Version 14.29.30136.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /showIncludes main.c
Microsoft(R) C/C++ Optimizing Compiler Version 19.29.30136 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
メモ: インクルード ファイル:  C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h
メモ: インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt.h
メモ: インクルード ファイル:    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h
メモ: インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\sal.h
メモ: インクルード ファイル:      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\concurrencysal.h
メモ: インクルード ファイル:     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vadefs.h
メモ: インクルード ファイル:   C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_wstdio.h
メモ: インクルード ファイル:    C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_stdio_config.h
Microsoft (R) Incremental Linker Version 14.29.30136.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj

Regards,
Tetsuya Mishima

I observed similar garbage messages. I could fix it by removing Japanese language pack and installing English instead. Modify Visual Studio workloads, components, & language packs | Microsoft Learn
FYI I’m using VS2022 community 14.37.32822