Installing STIR with CMake: Difference between revisions

From STIR
stir>Krthie
first version
 
stir>Krthie
more info
Line 10: Line 10:


= Step 1: Run cmake =
= Step 1: Run cmake =
First select source directory: STIR
== Launching CMake==
Select build directory. Best to use one level up from STIR. Call it anything you like, but e.g. STIR-bin
If you have Windows or MacOSX, CMake comes as an application with a nice GUI. After launching it, you
 
first select the source directory (STIR) and then a build directory. It's recommended to build one level up from STIR. Call it anything you like, but e.g. STIR-bin. (On Unix/Linux/MacOSX you will probably be using ''make'' to build things. In that case, you want different build directories for every type of build (Debug or Release) you want to make. On Windows when using Visual Studio, you can build different versions from one CMake configuration).


On Unix/linux (or MacOSX from a terminal window), you have to use a slightly more basic user interface. You would launch this as follows.
<pre>
mkdir STIR-bin
mkdir STIR-bin
cd STIR-bin
cd STIR-bin
ccmake ../STIR
mkdir Release
cd Release
ccmake ../../STIR
</pre>


Press Configure button (or c key)
Once CMake has started, you have to press the 'Configure' button (or c key).
You might get a "help" screen with some information, which you'll need to cloes (After reading the information of courses). For example, if some required libraries are missing, it will tell you. e.g. saying that FindBoost.cmake cannot find boost. You then
You might get a "help" screen with some information, which you'll need to cloes (After reading the information of courses). For example, if some required libraries are missing, it will tell you. e.g. saying that FindBoost.cmake cannot find boost. You then
get back to a screen with the configuration variables, where you can adjust things. For example, if you installed boost somewhere where cmake didn't find it, you can edit its location there. Similarly, for the ECAT LLN library you can  
get back to a screen with the configuration variables, where you can adjust things. For example, if you installed boost somewhere where cmake didn't find it, you can edit its location there. Similarly, for the ECAT LLN library you can  
specify the location of its include files and the library you want to link with.
specify the location of its include files and the library you want to link with.


If you change one of the variables, you will have to ''configure'' again. Once you are happy, you have to press ''generate''.
If you change one of the variables, you will have to ''configure'' again.  
 
For example, on my Linux system, the variables end up to something like this.
For example, on my Linux system, the variables end up to something like this.
<pre>
<pre>
Line 30: Line 34:
  BOOST_ROOT                                                                     
  BOOST_ROOT                                                                     
  BUILD_SHARED_LIBS                OFF                                           
  BUILD_SHARED_LIBS                OFF                                           
  CMAKE_BUILD_TYPE                                                            
  CMAKE_BUILD_TYPE                 Release
  CMAKE_INSTALL_PREFIX            /home/kris/                 
  CMAKE_INSTALL_PREFIX            /home/kris/                 
  CURSES_CURSES_H_PATH            /usr/include                                 
  CURSES_CURSES_H_PATH            /usr/include                                 
Line 49: Line 53:
</pre>
</pre>


After this, you can quit CMake.
The 'DISABLE_*' variables allow you to disable some features, even if you have the necessary libraries.
 
Once you are happy, you have to press ''generate''. After this, you can quit CMake.


== Stage 2: actual compilation ==
== Stage 2: actual compilation ==
Line 56: Line 62:


=== Unix-type systems: make ===
=== Unix-type systems: make ===
CMake will have created a series of directories in STIRbin with a series of Makefiles. To build STIR, you just type
CMake will have created a series of directories in STIR-bin with a series of Makefiles. To build STIR, you just type
<pre>
<pre>
make
make
Line 70: Line 76:
make install
make install
</pre>
</pre>
=== Windows and other systems with an IDE for compilation ===
CMake will have created a series of directories in the build directory with the necessary projects files. For example, for
Visual studio, there will be a STIR.sln with targets ALL_BUILD, INSTALL, RUN_TESTS (and projects for every for every library and executable). You would open the STIR solution, and build the relevant target. Remeber to set the type of build (Release or Debug) first from your GUI.

Revision as of 14:57, 2 February 2012

This page is under construction

Installing STIR with CMake

CMake is a cross-platform tool for building projects.

CMake FAQ How to sue a different compiler


Step 1: Run cmake

Launching CMake

If you have Windows or MacOSX, CMake comes as an application with a nice GUI. After launching it, you first select the source directory (STIR) and then a build directory. It's recommended to build one level up from STIR. Call it anything you like, but e.g. STIR-bin. (On Unix/Linux/MacOSX you will probably be using make to build things. In that case, you want different build directories for every type of build (Debug or Release) you want to make. On Windows when using Visual Studio, you can build different versions from one CMake configuration).

On Unix/linux (or MacOSX from a terminal window), you have to use a slightly more basic user interface. You would launch this as follows.

mkdir STIR-bin
cd STIR-bin
mkdir Release
cd Release
ccmake ../../STIR

Once CMake has started, you have to press the 'Configure' button (or c key). You might get a "help" screen with some information, which you'll need to cloes (After reading the information of courses). For example, if some required libraries are missing, it will tell you. e.g. saying that FindBoost.cmake cannot find boost. You then get back to a screen with the configuration variables, where you can adjust things. For example, if you installed boost somewhere where cmake didn't find it, you can edit its location there. Similarly, for the ECAT LLN library you can specify the location of its include files and the library you want to link with.

If you change one of the variables, you will have to configure again. For example, on my Linux system, the variables end up to something like this.

 AVW_ROOT_DIR                                                                  
 BOOST_ROOT                                                                    
 BUILD_SHARED_LIBS                OFF                                          
 CMAKE_BUILD_TYPE                 Release
 CMAKE_INSTALL_PREFIX             /home/kris/                
 CURSES_CURSES_H_PATH             /usr/include                                 
 CURSES_FORM_LIBRARY              /usr/lib/libform.so                          
 CURSES_HAVE_CURSES_H             /usr/include/curses.h                        
 DISABLE_AVW                      OFF                                          
 DISABLE_LLN_MATRIX               OFF                                          
 DISABLE_RDF                      OFF                         
 DISABLE_STIR_LOCAL               OFF                          
 GRAPHICS                         X                                            
 LLN_INCLUDE_DIRS                 /home/kris/devel/lln/ecat                    
 LLN_LIBRARIES                    /home/kris/devel/lln/ecat/debuggcc_64/libecat.a
 RDF_INCLUDE_DIRS                 RDF_INCLUDE_DIRS-NOTFOUND                    
 RDF_LIBRARIES                    RDF_LIBRARIES-NOTFOUND                       
 STIR_LOCAL                       /home/kris/devel/STIR/local        
 STIR_MPI                         OFF                                           
 STIR_OPENMP                      OFF                                          

The 'DISABLE_*' variables allow you to disable some features, even if you have the necessary libraries.

Once you are happy, you have to press generate. After this, you can quit CMake.

Stage 2: actual compilation

The previous step used CMake to generate files for the build system appropriate for your OS. Now, you need to use the build system to compile STIR. We just list the 2 most common ones:

Unix-type systems: make

CMake will have created a series of directories in STIR-bin with a series of Makefiles. To build STIR, you just type

make

If there are compilation problems, you might want to see the compilation commands:

make VERBOSE=1

You would normally finish with

make install

Windows and other systems with an IDE for compilation

CMake will have created a series of directories in the build directory with the necessary projects files. For example, for Visual studio, there will be a STIR.sln with targets ALL_BUILD, INSTALL, RUN_TESTS (and projects for every for every library and executable). You would open the STIR solution, and build the relevant target. Remeber to set the type of build (Release or Debug) first from your GUI.