MantisBT - CMake
View Issue Details
0013116CMakeCMakepublic2012-04-09 22:422012-09-03 16:00
hume npx 
Brad King 
normalmajoralways
closedno change required 
windowswin7 x64win7 x64 sp1
 
 
0013116: Cmake Nmake generator generate empty /MACHINE:for first run under a project
Cmake Nmake generator generate empty /MACHINE: for first run under a folder that make the compilation failed, if delete the folder contents and run the same cmake command again, then everything works as expected and /MACHINE:x86 is properly generated in the makefiles.
t.c
#include <stdio.h>

/* main entry */
int
#if defined(_MSC_VER)
__cdecl
#endif
main(int argc, char *argv[]) {
  printf("Hello world!\n");
  return 0;
}


CMakeLists.txt
cmake_minimum_required(VERSION 2.8)

project(test)

add_executable(test t.c)

then bring up cmd prompt and run under the folder:
cmake -G "NMake Makefiles" .

would result error if you run nmake

delete all the generated temp files and run the above step again, everything worked.
No tags attached.
Issue History
2012-04-09 22:42hume npxNew Issue
2012-04-10 10:25Brad KingNote Added: 0029110
2012-04-10 10:44hume npxNote Added: 0029111
2012-04-10 10:50hume npxNote Added: 0029112
2012-04-10 10:51Brad KingNote Added: 0029113
2012-04-10 22:07hume npxNote Added: 0029122
2012-04-10 22:08hume npxNote Added: 0029123
2012-04-11 07:58Brad KingNote Added: 0029124
2012-04-11 07:58Brad KingStatusnew => resolved
2012-04-11 07:58Brad KingResolutionopen => no change required
2012-04-11 07:58Brad KingAssigned To => Brad King
2012-09-03 16:00David ColeNote Added: 0030850
2012-09-03 16:00David ColeStatusresolved => closed

Notes
(0029110)
Brad King   
2012-04-10 10:25   
I cannot reproduce this. I get /machine:X86 on the link line after the very first configuration.

What version of CMake are you testing?
(0029111)
hume npx   
2012-04-10 10:44   
version is cmake 2.8.7 platform is win7 x64 for 32 bit vc environment, OS language is eastern, msvc is 10.0 newest patch.

in CmakeCache.txt, the wrong line is:

//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING=' /STACK:10000000 /machine: '

//Flags used by the linker during debug builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL:YES

//Flags used by the linker during release minsize builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
(0029112)
hume npx   
2012-04-10 10:50   
in my test in order to reproduce it, I must close all cmd.exe instance and reopen one, if not all cmd.exe closed after successful cmake build for second time, then it would work as expected.
(0029113)
Brad King   
2012-04-10 10:51   
I have the same environment except the OS language is English:

>type ..\CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(test)
add_executable(test t.c)

>type ..\t.c
#include <stdio.h>

/* main entry */
int
#if defined(_MSC_VER)
__cdecl
#endif
main(int argc, char *argv[]) {
  printf("Hello world!\n");
  return 0;
}

>cmake --version
cmake version 2.8.7

>cmake .. -G"NMake Makefiles"
-- The C compiler identification is MSVC
-- The CXX compiler identification is MSVC
-- Check for CL compiler version
-- Check for CL compiler version - 1600
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - no
-- Check for working C compiler: c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe
-- Check for working C compiler: c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe -- 
works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe

-- Check for working CXX compiler: c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe 
-- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done

>type CMakeCache.txt
... CMAKE_EXE_LINKER_FLAGS:STRING=' /STACK:10000000 /machine:X86 ' ...

>type CMakeFiles\test.dir\build.make
... /machine:X86 ...

>nmake
>test
Hello world!


Please attach your CMakeFiles\*.log files from a fresh run.
(0029122)
hume npx   
2012-04-10 22:07   
Oh,finally I reasoned out what caused the strange result, it's because I run the cmake .. -G"NMake Makefiles"
without setting vcvars.bat first, then I saw the cmake error message need to setup and run vcvars.bat, I just run it, now second time run cmake just works, but the flags in cmakecache.txt is obviously wrong.

so this may not be a bug, but an improvement that cmake can make to sugguest unsccessfull run exists and delete cache files, just like the suggestions make as to different compiler runs.
(0029123)
hume npx   
2012-04-10 22:08   
however thanks, this can be closed.
(0029124)
Brad King   
2012-04-11 07:58   
Thanks for reporting back.
(0030850)
David Cole   
2012-09-03 16:00   
Closing resolved issues that have not been updated in more than 4 months.