<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>I just got cmake working with C++ VS2010 .NET, so I thought I'd describe what I did, since the email archive and bug database were the most useful "tutorials" that I found.<br><br>My Goal: Create a VS2010/CLR project using cmake.<br>My Approach: Create the most trivial code using VS2010, and get a cmake CMakeLists.txt that will compile it with nmake so that it runs (the "hello world" is created automatically by VS2010). At that point, I'll know I've got a working CMakeLists.txt for a .NET project.<br><br>The steps:<br>0) Download cmake.<br>1) In VS2010 create a project and specify a console app using CLR. Try running it to make sure it prints "Hello World". (eg Projects\AJunkProj)<br>2) Create a parallel directory beside it in Projects. (eg. Projects\AJunkProjBld)<br>3) Create a CMakeLists.txt
in Projects\AJunkProj\AJunkProj. File shown below.<br>4) Launch a shell window from inside VS2010 to run cmake (otherwise, cmake environment won't find compilation tools). cd to your build directory (eg. Projects\AJunkProjBld)<br>5) Run: cmake ..\AJunkProject\AJunkProject <br>6) At this point, for me, there were no errors. So Run: nmake<br>7) The executable should now exist for you to run (eg. AJunkProj.exe)<br>In theory, you should be able to debug using nmake VERBOSE=1, though I only got it to display the first level of make commands.<br><br>I then ran: cmake -G "Visual Studio 10" ..\AJunkProject\AJunkProject<br>But I haven't inspected the generated project closely to see if it compiles properly (or at all.)<br><br># My CMakeLists.txt file <br>PROJECT(AJunkProject)<br>cmake_minimum_required(VERSION 2.8)<br>SET(PROJ_SRCS<br> AJunkProject.cpp <br> AssemblyInfo.cpp <br> stdafx.cpp<br>)<br><br># Mail archive
recommended app.rc be added to file list later...don't know why.<br>IF(WIN32)<br> SET(PROJ_SRCS ${PROJ_SRCS}<br> app.rc<br> )<br> # add a -l<path> to the typical link line.<br> TARGET_LINK_LIBRARIES(<br> wsock32<br> )<br>ENDIF(WIN32)<br><br># where to find header files...slashes must by unix style<br>INCLUDE_DIRECTORIES("C:/Program Files/Microsoft Visual Studio 10.0/VC/include")<br><br># From Mantis bug tracking notes...To set /clr flag for compiler <br>STRING(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})<br>STRING(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})<br>SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr")<br><br># set up a target<br>ADD_EXECUTABLE(AJunkProject ${PROJ_SRCS})<br>#==========<br><br>I realize that my CMakeLists.txt is still pretty rough. It has a
couple of unneeded lines and should have more placed inside IF(WIN32), but I'm glad just to have it working.<br><br>Thanks for creating cmake,<br>Tony<br></div>
</div><br>
</body></html>