Using cmake to build SimpleITK

Hi guys,

So i followed the tutorial I found here: to build the latest unreleased SimpleITK version.

I downloaded cmake and I made a map in the parent folder. I changed my path in the command prompt to this parent folder. I then used the cmake …\Superbuild command to build SimpleITK. This didn’t work. I searched for hours online and found some half solutions but none was explained decently and I can’t get it to work. The error that I receive is the following:

I’m sorry that it’s an image but I couldn’t copy paste from my command prompt. Any help is greatly appreciated.

EDIT: I tried to use the gui and the microsoft visual studio 2010 tool, but than i get: ` C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe

to get the value of VCTargetsPath:

Microsoft (R) Build Engine version 4.7.2046.0

[Microsoft .NET Framework, version 4.0.30319.42000]

Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/30/2017 10:26:02 PM.

Project "C:\Users\jeroen\Documents\2eMaster\Simple ITK build\CMakeFiles\3.9.4\VCTargetsPath.vcxproj" on node 1 (default targets).

C:\Users\jeroen\Documents\2eMaster\Simple ITK build\CMakeFiles\3.9.4\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Done Building Project "C:\Users\jeroen\Documents\2eMaster\Simple ITK build\CMakeFiles\3.9.4\VCTargetsPath.vcxproj" (default targets) -- FAILED.


"C:\Users\jeroen\Documents\2eMaster\Simple ITK build\CMakeFiles\3.9.4\VCTargetsPath.vcxproj" (default target) (1) ->

  C:\Users\jeroen\Documents\2eMaster\Simple ITK build\CMakeFiles\3.9.4\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    0 Warning(s)

    1 Error(s)


What you might need is to run cmake ../SimpleITK/SuperBuild (better yet, all of the commands) from a Visual Studio command prompt, usually found on the start menu under Visual Studio\Tools.

1 Like

Hi all, i’m sorry i’m getting another error now. I’m just confused where I should do what :stuck_out_tongue:

So just to recapitulate:
1 Does it matter where I place the SimpleITK source code? I put it in a random mydocuments directory. Does the name of the map with the SimpleITK source code matter?
2 I than made a map that i called ‘SimpleITK build’ (does this name matter?) in the parent folder of the SimpleITK source code.
3 Than i ran cmd and used the ‘cd’ command to change the path to the directory that i called ‘SimpleITK build’ in point 2.
4 Finally I ran the command cmake …\SimpleITK source code map\ Superbuild

Is this processus correct?

1 Like

Hi @Pythonsegmenter,

Yes, overall, that is generally the correct approach.

A few details to watch out for:

  1. The path to the source tree and the build tree should be short because of a command line length limitation on Windows. For example, C:\SimpleITK and C:\SimpleITK-build.

  2. Avoid spaces in your paths to prevent common errors when working on the command line.

Hope this helps,


Hi Matt, in your example simpleitk-build is not in the parent folder of
simpleitk so this is not necessary? I’ll try a shorter path as soon as I
can find a place to charge my battery.

Sorry guys, still doesn’t work. I now put the source file just here: C:\SimpleITK
and the build folder here: C:\SimpleITK-build
I ran everything from the command prompt.

I’m getting this error:

I have Visual Studio 2015, with this version it is called VS2015 x64 Native Tools Command Prompt. It sets the path to C++ compiler cl and other compiler-related tools. Just running this from an ordinary command prompt usually does not work.

Instead of the command prompt, you might use CMake-GUI, and select appropriate VS version when clicking Configure the first time.

Thanks for the reply dzenans, I downloaded the latest version of visual studios (2017) and I ran it from the VS command prompt. However the result is the same:

CMake always seems to find one of my Visual Studios compilers. Have you launch the VS GUI? Perhaps that will do some user configuration needed for your environment. Then reboot to get your environment changes.

Those same steps work on my computer. When you installed VS2017, did you chose component “Desktop development with C++”? If not, that would explain your problems. If that is not the issue, which version of CMake are you using?

To check whether path to C++ compiler has been set, type cl /? in VS command prompt. Here is the output on my computer:

** Visual Studio 2017 Developer Command Prompt v15.4.2
** Copyright (c) 2017 Microsoft Corporation

C:\Users\Dzenan\source>cl /?
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25547 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

‘cmake’ is not recognized as an internal or external command, operable program or a patch file.

This error means that the program cmake.exe is not found in the PATH environmental variable. You can either add the appropriate path with cmake.exe to your PATH environmental, it is something like C:\Program Files\CMake\bin, or automatic addition to the PATH environmental variable may be an option in the CMake installer.

– Building for: NMake Makefiles

This may be caused by CMake trying to create NMake Makefiles before, so it will try again. To address this issue, remove the contents of C:\SimpleITK-build before running cmake again.

If C:\SimpleITK-build is already clean, then explicitly specify what CMake should generate with the -G flag, i.e.

cmake -G "Visual Studio 15 2017" C:\SimpleITK\Superbuild

Thanks Matt, I could indeed resolve this issue this way :slight_smile: Now I’m just still stuck on the C++ compiler not being found.

@blowekamp I launched the GUI, but I’ll reboot later (takes a while and i actually have to study for an exam) but it certainly has no immediate effect.

@dzenanz I don’t remember whether I chose that, is there a way to check this? The output I get is that it isn’t found:

Hi Matt,

I did what you said: cmake -G “Visual Studio 15 2017” C:\SimpleITK\Superbuild

This is what I got from the VS cmd prompt:

Hi @Pythonsegmenter,

It sounds like an issue with the Visual Studio installation. It may help to verify that the Visual Studio installation includes C++ development support.

1 Like

I suggest to restart your computer. To check which components you have, run “Visual Studio Installer” and click “Modify”. On my computer it is located here: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe

1 Like

Hi guys!
Sorry it has been a while, but i had to focus on a couple of other things before continuing my building quest. You guys were right, I accidently installed a Visual studio version without the developper options. After adding the developer options to my Visual Studios installation and running the cmake command from the visual studios command prompt I advanced! So thanks a lot!

You might have noticed the usage of ‘advanced’ and not ‘worked’. This is because I got a new error :). Any ideas for this one:

The original question of this post is actually solved, should I make a new one?

Thanks for all your help

Found the solution myself, i lacked the ‘git’ program apparently :slight_smile:

Just a tip, for your guide (this one:, if you want that the absolute noobs like me understand it:
-Add that ‘run the following commands’ should be done in the command prompt. I initially didn’t know where.
-Add that you should download cmake (I didn’t know it was a program)
-Add that you should download a Visual studio program with developer options
-Add that you should download git
I guess that then things would have been a lot clearer for me. It’s just some feedback. Do with it whatever you want.




Most of the information you want us to add actually appears at the top of the page you referenced, prerequisites section. Still, this shows us that we need to point to that section from each of the sub sections.

Your feedback is helpful, so don’t stop “complaining”, you are helping us improve the documentation and its layout for everyone’s benefit.

This pull request should address the issues:


Hi guys,

I still have a final follow-up question on this topic :slight_smile:

It has been a while since I first had some exams. I thought I completed the quest because I builded the package succesfully. However the package still has to be installed in python. I followed the tutorial further down and I found the necessary commands. However, when I execute them I get the error that ‘’ doesn’t exist. Which is indeed the case, but I did find ‘’. I found it in the source folder but I guess it should be in the build folder, but it isn’t. There’s nothing in the SimpleITK-build\SimpleITK-build folder.

Here’s a screenshot of what happens when I try to run the commands as explained in the tutorial:

As always all help is appreciated