5

I am learning how to use CMake,

I am converting a working project from Visual Studio to Cmake and building with NMake. The current projects builds for both x64 and x86

My current CMakeLists.txt is very simple:

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
    )

The error I get is

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

I understand the way NMake chooses which compiler to use, x86 or x64, is by opening the appropriate console terminal. I am using Select x64 Native Tools Command Prompt for VS 2017

The command line for the linker that gets executed is:

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'

I can see it has /machine:X86 set in it. I am not setting this in CMakeLists.txt. How can I make it use a 64 bit linker?

I tried adding suggested arguments to the cmake call, it did not make a difference cmake -G"NMake Makefiles" --build build64 --config Release -host_arch=amd64 -arch=amd64 ..

Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.