Build failed after change architecture from x64 to x86_64 using cmake preset on windows

578 Views Asked by At

I'm building a project using cmake preset in vs2019. My CMakePresets.json as follows:

    {
  "name": "windows-x86_64-release",
  "displayName": "Windows x86_64 Release",
  "description": "Target Windows with the Visual Studio development environment.",
  "generator": "Ninja",
  "binaryDir": "${sourceDir}/build/${presetName}",
  "architecture": {
    "value": "x64",
    "strategy": "external"
  },

My windows is 64 bit. The settings above works well. Because VS is alway 32 bit, so I change architecture value to x86_64, then I get an error when cmake init:

1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
1> [CMake]   The C compiler
1> [CMake] 
1> [CMake]     "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/HostX64/x86/cl.exe"
1> [CMake] 
1> [CMake]   is not able to compile a simple test program.
1> [CMake] 
1> [CMake]   It fails with the following output:
1> [CMake] 
1> [CMake]     Change Dir: D:/code_repo/repo_sun/qrlib/alib/code/build/windows-x86_64-release/CMakeFiles/CMakeTmp
1> [CMake]     
1> [CMake]     Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_c3232 && [1/2] Building C object CMakeFiles\cmTC_c3232.dir\testCCompiler.c.obj
1> [CMake]     [2/2] Linking C executable cmTC_c3232.exe
1> [CMake]     FAILED: cmTC_c3232.exe 
1> [CMake]     cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_c3232.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1428~1.299\bin\HostX64\x86\link.exe /nologo CMakeFiles\cmTC_c3232.dir\testCCompiler.c.obj  /out:cmTC_c3232.exe /implib:cmTC_c3232.lib /pdb:cmTC_c3232.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
1> [CMake]     RC Pass 1: command "rc /fo CMakeFiles\cmTC_c3232.dir/manifest.res CMakeFiles\cmTC_c3232.dir/manifest.rc" failed (exit code 0) with the following output:
1> [CMake]     系统找不到指定的文件。
1> [CMake]     ninja: build stopped: subcommand failed.

Mean while, the follow script works well in cmd prompt:

set build_type=windows-x86_64-release
md build
cd build
cmake .. --preset=%build_type%
cd %build_type%
ninja install

Any idea about that?

0

There are 0 best solutions below