Using CMake on Windows with special requirements: Difference between revisions

From STIR
stir>Krthie
m corrected link to main page
stir>Krthie
some formatting and clarification on system path when using swig
Line 4: Line 4:


If you need to let CMake find executables or dlls in a particular location, you can either  
If you need to let CMake find executables or dlls in a particular location, you can either  
* add its location to your system path,  
* add its location to your system path (via the ''System'' control panel, click on ''Advanced Settings'', select ''Environment Variables''),
* or modify the CMake-gui shortcut to set this location as the CMake startup,  
* or modify the CMake-gui shortcut to set this location as the CMake startup,  
* or open a command  
* or open a command prompt, '''cd''' to the directory (or add it to the path) and launch CMake from there, possibly via something like
prompt, '''cd''' to the directory and launch CMake from there, possibly via something like
<pre>"c:\Program Files (x86)\CMake 2.8\bin\cmake-gui"</pre>
<pre>"c:\Program Files (x86)\CMake 2.8\bin\cmake-gui.exe"</pre>
Below are some examples where this strategy would be necessary.
Below are some examples where this strategy would work.


=== Using the Windows SDK even if you have Visual Studio installed ===
=== Using the Windows SDK even if you have Visual Studio installed ===
Line 20: Line 19:
* When pressing "Configure", you will have to use a "generator" that is compatible with the SDK. "nmake" should work. For SDK 7.1, you could use "Visual Studio 10" and then build via "msbuild" (see main page).
* When pressing "Configure", you will have to use a "generator" that is compatible with the SDK. "nmake" should work. For SDK 7.1, you could use "Visual Studio 10" and then build via "msbuild" (see main page).


=== Using SWIG compiled with Cygwin ===
=== Using SWIG compiled with Cygwin while using Visual Studio for compilation of STIR ===
''STIR'' can use ''SWIG'' to generate an interface to Python (or soon MATLAB). You can download
''STIR'' can use ''SWIG'' to generate an interface to Python (or soon MATLAB). You can download
''SWIG'' executables for Windows from its website. However, in case you want to use a brand-new
''SWIG'' executables for Windows from its website. However, in case you want to use a brand-new
version of ''SWIG'', you will need to build it yourself. At present (end 2014), ''SWIG''
version of ''SWIG'', you will need to build it yourself. At present (end 2014), ''SWIG''
can only be build on Linux-type systems. You could try to use ''MSYS'' (after downloading
can only be build on Linux-type systems. You could try to use ''MSYS'' (after downloading
a number of packages), but it is relatively easy with ''Cygwin'' (after installing autoconf, bison etc).
a number of packages), but it is easier with ''Cygwin'' (after installing autoconf, bison etc).
However, now you need to point CMake to the swig executable, which will only run if CMake will find your ''cygwin1.dll''. Add its location (which could be ''c:\cygwin64\bin'') to your path as above.
However, now you need to point CMake to the swig executable, which will only run if CMake will find your ''cygwin1.dll''. In addition, when building STIR, Visual Studio will need to run swig, so the recommended method is to add the location of the cygwin dll (which could be ''c:\cygwin64\bin'') to your system path ''before'' starting CMake.

Revision as of 00:27, 24 November 2014

This page provides instructions for building STIR with CMake on Windows in special corner cases. Most people will not need this and just want to refer to the normal build instructions at Installing_STIR_with_CMake.

If you need to let CMake find executables or dlls in a particular location, you can either

  • add its location to your system path (via the System control panel, click on Advanced Settings, select Environment Variables),
  • or modify the CMake-gui shortcut to set this location as the CMake startup,
  • or open a command prompt, cd to the directory (or add it to the path) and launch CMake from there, possibly via something like
"c:\Program Files (x86)\CMake 2.8\bin\cmake-gui"

Below are some examples where this strategy would be necessary.

Using the Windows SDK even if you have Visual Studio installed

You might want the use the compilers from the Windows SDK, for instance for compatibility with some external library.

If you didn't add the SDK to the system path, CMake will not find it. One solution for this is as follows:

  • launch CMake from an SDK command prompt (there is probably an SDK folder in your Start menu with an appropriate entry)
  • When pressing "Configure", you will have to use a "generator" that is compatible with the SDK. "nmake" should work. For SDK 7.1, you could use "Visual Studio 10" and then build via "msbuild" (see main page).

Using SWIG compiled with Cygwin while using Visual Studio for compilation of STIR

STIR can use SWIG to generate an interface to Python (or soon MATLAB). You can download SWIG executables for Windows from its website. However, in case you want to use a brand-new version of SWIG, you will need to build it yourself. At present (end 2014), SWIG can only be build on Linux-type systems. You could try to use MSYS (after downloading a number of packages), but it is easier with Cygwin (after installing autoconf, bison etc). However, now you need to point CMake to the swig executable, which will only run if CMake will find your cygwin1.dll. In addition, when building STIR, Visual Studio will need to run swig, so the recommended method is to add the location of the cygwin dll (which could be c:\cygwin64\bin) to your system path before starting CMake.