Views
Windows instructions using CMake
Building Cmgui using CMake and Microsoft Visual Studio
The following is a description of how to build Cmgui on a Windows 7 (64 bit) machine using CMake and Microsoft Visual Studio. The following will assume that the PC currently contains none of the required software. Maybe your PC already has some of the required software, if so then feel free to skip the relevant parts.
Some advice, have a good read through these instructions first and then another read through each subsection when you reach it. It will hopefully give you the understanding necessary if things don't quite go to plan.
Software Requirements
Here is a list of all the software required:
- CMake - minimum version 2.8.2
- An svn client - TortoiseSVN is good and widely used
- Perl - Active perl community edition
- Patch - GNU Patch for windows
- Visual Studio Express
If you want to build 64 bit applications then you also need:
- Microsoft SDK v7.1
Download Software
To download the required software the following is a list of places to start.
- CMake - http://www.cmake.org/cmake/resources/software.html
- TortoiseSVN - http://tortoisesvn.net/downloads.html
- Perl - http://www.activestate.com/activeperl/downloads
- Patch - http://gnuwin32.sourceforge.net/packages/patch.htm
- Visual Studio Express 2010 - http://www.microsoft.com/express/Downloads/
- Microsoft SDK - http://msdn.microsoft.com/en-us/windows/bb980924
The versions of the above software used in this page are
- cmake-2.8.4-win32-x86 (yes 32 bit) {8 MB}
- TortoiseSVN-1.6.1621511-x64-svn-1.6.17 {17 MB}
- ActivePerl-5.12.3.1204-MSWin32-x64-294330
- patch-2.5.9-7-setup
- Microsoft Visual Studio 2010 Express
- Microsoft SDK v7.1
Install Software
Now install that lot. For Visual Studio you will have to register the product to use it for longer than the evaluation period (30 days). For this you need a windows live id. Something you will need to sort out for yourself.
- Say 'yes' to add CMake to the system path
- Say 'yes' to add perl to the system path
I used the Microsoft Help Viewer application to download some help files
- Visual Studio C++ Help
- And something else that I thought might be useful but can't remember what???
Tortoise svn requires you to restart your system (to integrate with windows explorer) so install this last. Also as a side note when I went through this process on Windows XP Visual Studio forced a restart on me so perhaps do this last and save yourself a restart.
With everything installed I used approximately 4 GB of hard disk drive space.
Environment Build Pre-requisites
When building Cmgui the environment variable:
CMISS_ROOT
is used to identify the location of several important dependencies. Defining this with as a system environment variable saves a bit of typing. Otherwise you need to input it in several places during the build. Also if any CMake dependencies are changed then it will also need to be set for CMake to make any changes.
So I created a folder 'cmiss' on my 'D:' drive and using the environment variable dialog set CMISS_ROOT to be the following:

After I did this I added the location of the patch.exe executable to my PATH environment variable. For me, this meant appending the following text to the PATH environment variable:
;C:\Program Files (x86)\GnuWin32\bin
The semicolon at the front is a separator so you may just copy and paste this string (if you are on a 64 bit Windows operating system). To test this is working bring up a new Visual Studio Command Prompt and type:
patch -v
If the 'User Account Control' dialog pops up great, we will disable this in a bit. If on the other hand you get a message to the effect that "'patch' is not recognized as an internal or external command." then things have gone wrong.
Lastly, I created a subfolder of 'cmiss' called 'setup' where I downloaded this CMake script (Right click and choose 'save target/link as...').
Windows 7 User Access Control
For us this is bad. It just doesn't like the patch.exe program. We need to disable this for the duration of building Cmgui's Dependencies. To disable UAC we need administrator priveleges then we can do the following.
Disable and Turnoff UAC in Windows 7 from Control Panel
- Access User Control Panel from Start Menu -> Control Panel -> User Accounts and Family Safety -> User Account
- Click on User Account Control settings link.
- Move the Slider to Never Notify
- Click OK to make the change effective
- Reboot
Now we are ready to actually start building some software.
Building Cmgui Dependencies
Open up a Visual Studio command prompt. Make sure it is a Visual Studio command prompt because it sets up the build environment for us. In my case I find it under:
Start/All programs/Microsoft Visual Studio 2010 Express/Visual Studio Command Prompt (2010)
I actually right click on this menu item and pin it to the taskbar and pin it to the Start Menu to make it easily accessible.
In the command prompt execute the following commands:
d: cd cmiss\setup cmake-gui
Now set the cmake-gui up to have:
- 'Where is the source code:' d:/cmiss/setup
- 'Where to build the binaries:' d:/cmiss/setup/build
then press the 'Configure' button choose your generator as 'NMake Makefiles' and configure away, now press 'Configure' again until you have no more red highlighting and then 'Generate'. Now we can run the following commands:
cd build nmake
Now you are going to see a succession of subversion checkout dialogs appear. When the first dialog appears you should get asked whether you are willing to accept the security certificate, I accept it permanently - if you trust us I suggest you do the same, if you don't trust us then we are stuck! The destinations are preset so all you have to do is press the 'Ok' button to continue. The subversion checkout dialogs should appear in the following order:
- Cmgui CMake modules
- perl interpreter
- third_party (may take awhile depending on your connection speed.)
- cmgui
Now you wait while everything builds ... you will need to wait a while ... quite a while.
The Last Step
At the successful completion of the build we still need to do a couple of jobs to finish off. What the above steps have done is to compile all the dependencies of Cmgui and setup a Visual Studio solution for developing Cmgui. To finish off all we need do is open the Cmgui Visual Studio solution file in Visual Studio and build the ALL_BUILD target. This will build a Debug or Release version of Cmgui depending on the current build configuration.
Enjoy.
That Script Again
CMake Cmgui build script: https://svn.physiomeproject.org/svn/cmiss/cmake/trunk/cmgui/CMakeLists.txt (Right click and choose 'save target/link as...')
If you encounter any issues with this script please leave a comment here.