CMake 致命错误 LNK1112:模块机器类型“x64”与目标机器类型“x86”冲突

Mi *_* Po 5 c++ windows nmake makefile cmake

我正在学习如何使用 CMake,

我正在将一个工作项目从 Visual Studio 转换为 Cmake 并使用 NMake 进行构建。当前项目为 x64 和 x86 构建

我当前的 CMakeLists.txt 非常简单:

cmake_minimum_required(VERSION 3.13.0)

project(SimManager CXX)

ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)

set(CMAKE_CXX_FLAGS -G"NMake Makefiles")

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(SimManager
    Source/main.cpp
    )

set_target_properties (${PROJECT_NAME} PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED TRUE
    CXX_EXTENSIONS FALSE
    )
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
Run Code Online (Sandbox Code Playgroud)

我了解 NMake 选择使用哪个编译器(x86 或 x64)的方式是打开适当的控制台终端。我在用Select x64 Native Tools Command Prompt for VS 2017

被执行的链接器的命令行是:

command "C:\PROGRA~2\MIB055~1\2019\ENTERP~1\VC\Tools\MSVC\1425~1.286\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\SimManager.dir\objects1.rsp /out:SimManager.exe /implib:SimManager.lib /pdb:E:\Projects\SimManager\Debug\SimManager.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 /MANIFEST /MANIFESTFILE:CMakeFiles\SimManager.dir/intermediate.manifest CMakeFiles\SimManager.dir/manifest.res" failed (exit code 1112) with the following output: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

我可以看到它已经/machine:X86设置在里面。我没有在 CMakeLists.txt 中设置它。如何使它使用 64 位链接器?

我尝试向 cmake 调用添加建议的参数,但没有任何区别 cmake -G"NMake Makefiles" --build build64 --config Release -host_arch=amd64 -arch=amd64 ..

谢谢