C compiler identification is unknown despite setting CC and CXX variables - cmake

I'm using the command:
cmake CC="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"
CXX="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe" -G "Visual Studio 12
Win64" -DBOOST_ROOT="c:\local\boost_1_56_0" -DBOOST_LIBRARYDIR="c:\local\boost_1_56_0\lib64-
msvc-12.0" ..
It says:
The C compiler identification is unknown
and
The CXX compiler identification is unknown
How is it possible when I set those variables right there?
EDIT: Error log file:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 21-09-2014 20:17:49.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TC /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdC\CompilerIdC.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.47
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 12.0.30723.0
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 21-09-2014 20:17:50.
Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /nologo /W0 /WX- /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /errorReport:queue CMakeCXXCompilerId.cpp
CMakeCXXCompilerId.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [D:\foo\build\CMakeFiles\3.0.2\CompilerIdCXX\CompilerIdCXX.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.50

The compiler can be selected by using the CC and CXX variables, but by it's much more complicated than using the -G (generator) parameter. For one, the slashes in the path must be Unix style (/) and they don't take effect after the first time CMake configuration is ran unless the cache is cleared.
For a list of available generator options include the --help option
The paths to the Boost library must also use Unix style slashes (/). Many of the commands will convert Windows paths, but when passing in definitions at the command-line you'll want to always use Unix style paths.
Your command would change to the following:
cmake -G "Visual Studio 12 2013 Win64" -DBOOST_ROOT="C:/local/boost_1_56_0" -DBOOST_LIBRARYDIR="C:/local/boost_1_56_0/lib64-msvc-12.0" ..
You'll also want to make sure that your PATH environment variable is setup correctly for Visual Studio and x64. This can be done easily by opening a VS2013 x64 Native Tools Command Prompt using the command below:
cmd /k "%VS120CoMNTOOLS%\..\..\VC\vcvarsall.bat" amd64
In addition, you should make sure you're clearing out the cmake cache before you try. The easiest way to do this is to delete your cmake build folder, but you can also use the CMake-gui to clear the cache.

Related

"cannot open file 'user32.lib'" when trying to use Visual Studio 2005 on Windows 10

I'm attempting to match output with a C++ Win32 executable compiled with Visual Studio 2005, so I'm trying to use that MSVC to do so. I have a project defined in CMake. I open "Visual Studio 2005 Command Prompt", but when I try to cmake -G "NMake Makefiles" .. I get LINK : fatal error LNK1104: cannot open file 'user32.lib'.
Here's the CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
# set the project name
project(LEGOStarWarsSaga)
# add the executable
add_executable(LEGOStarWarsSaga src/main.cpp)
Here's the Visual Studio 2005 Command Prompt output:
C:\Users\aprim\Documents\lstsc>mkdir build
C:\Users\aprim\Documents\lstsc>cd build
C:\Users\aprim\Documents\lstsc\build>cmake -G "NMake Makefiles" ..
-- The C compiler identification is MSVC 14.0.50727
-- The CXX compiler identification is MSVC 14.0.50727
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeTmp
Run Build Command(s):nmake /nologo cmTC_41947\fast && "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_41947.dir\build.make /nologo -L CMakeFiles\cmTC_41947.dir\build
Building C object CMakeFiles/cmTC_41947.dir/testCCompiler.c.obj
C:\PROGRA~2\MI30EB~1\VC\bin\cl.exe #C:\Users\aprim\AppData\Local\Temp\nmBDB4.tmp
testCCompiler.c
Linking C executable cmTC_41947.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_41947.dir --rc=C:\PROGRA~2\MI30EB~1\VC\bin\rc.exe --mt=C:\PROGRA~2\MI30EB~1\VC\bin\mt.exe --manifests -- C:\PROGRA~2\MI30EB~1\VC\bin\link.exe /nologo #CMakeFiles\cmTC_41947.dir\objects1.rsp #C:\Users\aprim\AppData\Local\Temp\nmBE13.tmp
LINK Pass 1: command "C:\PROGRA~2\MI30EB~1\VC\bin\link.exe /nologo #CMakeFiles\cmTC_41947.dir\objects1.rsp /out:cmTC_41947.exe /implib:cmTC_41947.lib /pdb:C:\Users\aprim\Documents\lstsc\build\CMakeFiles\CMakeTmp\cmTC_41947.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL:YES /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\cmTC_41947.dir/intermediate.manifest CMakeFiles\cmTC_41947.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'user32.lib'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:4 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/aprim/Documents/lstsc/build/CMakeFiles/CMakeError.log".
After reading online, I've come to find that this is something to do with missing the Windows SDK. However, I have the Windows SDKs 7.1 and 10.0 installed. What am I missing?
Bonus points if there's a build tool that'll make this process (nearly) seamless for anyone cloning the project.
EDIT: Installing Visual Studio 2005 Professional with the full Visual C++ option installs the SDK properly, and the project builds. My worry is that not everyone has access to VS 2005 Pro.

Building ParaView-Superbuild in windows 10

I'm trying to build the ParaView-Superbuild (https://gitlab.kitware.com/paraview/paraview-superbuild) on Windows 10 64x.
I cannot manage to get it to work. I just ran from error to error. Currently I'm stuck at:
CMake Error at superbuild/projects/win32/boost.cmake:5 (message):
At least Visual Studio 9.0 is required
Call Stack (most recent call first):
superbuild/cmake/SuperbuildMacros.cmake:690 (include)
superbuild/CMakeLists.txt:145 (_superbuild_discover_projects)
using Cmake 3.13.10-rc1 as generator for Ninja. I have Cygwin64 installed and I'm using the GCC compiler
The C compiler identification is GNU 7.3.0
The CXX compiler identification is GNU 7.3.0
Since I thought that the error has something to do with the compiler I tried to switch to the installed VS2017 compiler. However, the build process will then crash with
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules
/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools
/MSVC/14.15.26726/bin/Hostx86/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/paraview-superbuild/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Ninja/ninja.exe" "cmTC_915a7"
[1/2] Building C object CMakeFiles\cmTC_915a7.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_915a7.exe
FAILED: cmTC_915a7.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe
--intdir=CMakeFiles\cmTC_915a7.dir --manifests -- C:\PROGRA~2\MICROS~1
\2017\ENTERP~1\VC\Tools\MSVC\1415~1.267\bin\Hostx64\x64\link.exe /nologo
CMakeFiles\cmTC_915a7.dir\testCCompiler.c.obj /out:cmTC_915a7.exe
/implib:cmTC_915a7.lib /pdb:cmTC_915a7.pdb /version:0.0 /machine:x64
/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 ."
RC Pass 1: command "rc /foCMakeFiles\cmTC_915a7.dir/manifest.res
CMakeFiles\cmTC_915a7.dir/manifest.rc" failed (exit code 0) with the
following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (
I don't know how to fix the error using the GCC compiler when the VS one is not working at all. Sadly, I couldn't find any help on the Paraview website.
Has somebody managed to build it and can show me step by step how to do it?
And no, I don't want to use Linux here.
Thanks.
Here is a reliable way to build ParaView Superbuild on windows
Install Visual Studio 2013 community with all C++ related tools
Install cmake
Install git bash
Install Ninja
Install Qt 5.9.2 VS2013
Install other potential dependencies
open git bash
then :
cd C:/
mkdir pv
cd pv
git clone git#gitlab.kitware.com:paraview/paraview-superbuild.git
mv paraview-superbuild pvsb
mkdir pvsb_b
cd pvsb
git submodule update --init --recursive
Open Visual Studio Native Command X64
then :
cd C:\pv\pvsb_b
cmake-gui
configure paraview-superbuild accordingly to your need
ENABLE_qt5 and USE_SYSTEM_qt should be ON
generate
close cmake-gui
ninja

VS 2017 cmake error

I am trying to build my code using 3d builder. Am using VS 2017 version. Previously it was working fine but after windows update while trying to open code using VS cmake compiler error. Hereby attaching the log files of error. Is anyone facing the same error? Could someone suggest a way to resolve it?
Build started 7/20/2018 6:39:28 PM.
Project "C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TP /FC /errorReport:queue CMakeCXXCompilerId.cpp
CMakeCXXCompilerId.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
LINK : fatal error LNK1104: cannot open file 'ucrtd.lib' [C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj]
Done Building Project "C:\code\dump64\CMakeFiles\3.8.20170425-g0257b-dirty\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets) -- FAILED.
Build FAILED.

Failed to configure CMake with Visual Studio 2010 Express

Can somebody help me please, I am trying to configure CMake with Visual Studio 2010 Express but it's failed. The whole error message is bellow :
The C compiler identification is MSVC 16.0.30319.1 The CXX compiler
identification is MSVC 16.0.30319.1 Check for working C compiler
using: Visual Studio 10 Check for working C compiler using: Visual
Studio 10 -- broken CMake Error at C:/Program Files/CMake
2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message): The C compiler "C:/Program Files/Microsoft Visual Studio
10.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/OpenCV2.2/build/CMakeFiles/CMakeTmp
Run Build
Command:C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
cmTryCompileExec2312584318.vcxproj /p:Configuration=Debug
/p:VisualStudioVersion=10.0
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 30/05/2013 20:16:01.
Project
"C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\cmTryCompileExec2312584318.vcxproj"
on node 1 (default targets).
PrepareForBuild:
Creating directory "cmTryCompileExec2312584318.dir\Debug\".
Creating directory "C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\Debug\".
InitializeBuildStatus:
Creating "cmTryCompileExec2312584318.dir\Debug\cmTryCompileExec2312584318.unsuccessfulbuild"
because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D
"CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Fo"cmTryCompileExec2312584318.dir\Debug\"
/Fd"C:/OpenCV2.2/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec2312584318.pdb"
/Gd /TC /analyze- /errorReport:queue testCCompiler.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Fo"cmTryCompileExec2312584318.dir\Debug\"
/Fd"C:/OpenCV2.2/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec2312584318.pdb"
/Gd /TC /analyze- /errorReport:queue testCCompiler.c
testCCompiler.c
ManifestResourceCompile:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"cmTryCompileExec2312584318.dir\Debug\cmTryCompileExec2312584318.exe.embed.manifest.res" cmTryCompileExec2312584318.dir\Debug\cmTryCompileExec2312584318_manifest.rc
Link:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:QUEUE
/OUT:"C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec2312584318.exe"
/INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
/MANIFEST
/ManifestFile:"cmTryCompileExec2312584318.dir\Debug\cmTryCompileExec2312584318.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG
/PDB:"C:/OpenCV2.2/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec2312584318.pdb"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
/IMPLIB:"C:/OpenCV2.2/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec2312584318.lib"
/MACHINE:X86
cmTryCompileExec2312584318.dir\Debug\cmTryCompileExec2312584318.exe.embed.manifest.res
cmTryCompileExec2312584318.dir\Debug\testCCompiler.obj /machine:X86 /debug
LINK : fatal error LNK1123: failure during conversion to COFF: file
invalid or corrupt
[C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\cmTryCompileExec2312584318.vcxproj]
Done Building Project
"C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\cmTryCompileExec2312584318.vcxproj"
(default targets) -- FAILED.
Build FAILED.
"C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\cmTryCompileExec2312584318.vcxproj"
(default target) (1) ->
(Link target) ->
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
[C:\OpenCV2.2\build\CMakeFiles\CMakeTmp\cmTryCompileExec2312584318.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.64
CMake will not be able to correctly generate this project. Call
Stack (most recent call first): CMakeLists.txt:47 (project)
Configuring incomplete, errors occurred!
any advice?
Install the windows 7 SDK then install VC-Compiler-KB2519277. Fixed the issue for me.
Was having the same problem with CMake on win7x64. The problem relates to .NET 4.5. If you don't want to uninstall 4.5, and your Solution is already setup, make sure to disable incremental linking, otherwise you will not be able to build.
To fix your CMake issue, you will have to uninstall .NET 4.5 on your machine and re-install .NET 4.0 in order to get CMake to work (4.5 removes all of 4.0's assemblies, etc!)
Apparently can't install 4.0 while 4.5 is already installed, so use Windows Control Panel to do the uninstall (Control Panel\Programs\Programs and Features)
CMake does not consider this a bug, rather it is a MS issue.
If you have Net framework 4.5 installed, you have to update VS 2010 to SP1 in order to make some stuff work correctly. Sometimes you can overcome the problem by just setting off incremental build in project Configurations > Linker settings. If you have VS 2012 installed after VS 2010, then before updating the VS 2010, you need to search at MSDN for the article about avoiding dependencies. My guess is that you will have to uninstall newer versions before upgrading the older ones to new service packs. There is a set of pages in MSDN explaining each step. Just google them. I also had this problem with CMake. This is how i solved it. Furthermore, i already had Windows 7 SDK installed. So i am not sure if it is needed to be installed to solve this problem or not.
In my case installing the VC2010 Service Pack 1 solved my issue after a reboot.
Didn't installed the Windows SDK 7.1 at all or anything else.
If you don't want to re-install .NET Frameworks and/or making 400mb Windows SDK updates, try this lighter solution first.

Can't build CUDA Test Application

Currently following the CUDA Getting Started guide for Microsoft Windows [ http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html ]; installed CUDA; the samples and NSight; im on Visual Studio 2010; I have checked my card and it supports CUDA. I followed the tutorials up to the demo parts... but I am getting the following error message:
====================================================================================
1>CudaBuild:
1> Compiling CUDA source file bandwidthTest.cu...
1>
1> C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\1_Utilities\bandwidthTest>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"./" -I"../../common/inc" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -DWIN32 -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o "Win32/Debug/bandwidthTest.cu.obj" "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\1_Utilities\bandwidthTest\bandwidthTest.cu"
1> bandwidthTest.cu
1>C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.0/1_Utilities/bandwidthTest/bandwidthTest.cu(117): error : identifier "cin" is undefined
1>
1> 1 error detected in the compilation of "C:/Users/James/AppData/Local/Temp/tmpxft_00001654_00000000-14_bandwidthTest.compute_35.cpp1.ii".
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"./" -I"../../common/inc" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -DWIN32 -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o "Win32/Debug/bandwidthTest.cu.obj" "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\1_Utilities\bandwidthTest\bandwidthTest.cu"" exited with code 2.
1>
1>Build FAILED.
====================================================================================
I acknowledge that cin is part of iostream which i have verified is part of my include directive in my code...
I am coming from a web developer's background; I rarely program these types...
I'm assuming you've modified the bandwidthTest.cu file and this is not the vanilla SDK sample (since a quick check shows it doesn't use cin by default!).
You either need to use std::cin to explicitely state the scope or add a using namespace std or using std::cin to either the top of your file (after including iostream) or the top of the function.
Searching for info on namespaces should give more background, e.g. this tutorial.
If this isn't the problem, then post some code.
Update
From your it seems comment, your real question is how to create a CUDA project in VS2010. See this answer for information on that! Basically you need to create .cu files in your project and then tell Visual Studio what to do with them (i.e. enable the build customisation).