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:
The building process itself is successfully done.
English version of VS2019 outputs no includes notification - it works fine.
When using /showIncludes option, the Japanese message is “メモ: インクルード ファイル:”.
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?
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.
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…
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:
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