MediaWiki has been updated to version 1.35.1. Please report any problems here.

Difference between revisions of "Building using CMake - Windows"

From FlightGear wiki
Jump to navigation Jump to search
(Note about steps, fix link, add building template.)
(Improve structure, first build SimGear. Explain 64 bits 3rdParty directory.)
Line 9: Line 9:
 
On Windows, assumptions on the directory structure are made to automate the discovery of dependencies.
 
On Windows, assumptions on the directory structure are made to automate the discovery of dependencies.
  
This recommended directory structure is described below. Clicking the links allows you to download pre-built parts.
+
This recommended directory structure is described below. Clicking the links allows you to download pre-built parts (for 3rdParty, make sure to download the right bits version. You need only one of the zips.).
 
<tt>
 
<tt>
 
: ${MSVC_3RDPARTY_ROOT} /
 
: ${MSVC_3RDPARTY_ROOT} /
 
:: [ftp://ftp.ihg.uni-duisburg.de/FlightGear/Win32/MSVC/ 3rdParty] / </tt> ( includes plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ... ) <tt>
 
:: [ftp://ftp.ihg.uni-duisburg.de/FlightGear/Win32/MSVC/ 3rdParty] / </tt> ( includes plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ... ) <tt>
::: bin /
 
::: include /
 
::: lib /
 
:: 3rdParty.x64 / </tt> ( 64 bit version ) <tt>
 
 
::: bin /
 
::: bin /
 
::: include /
 
::: include /
Line 31: Line 27:
 
::::: include /
 
::::: include /
 
::::: lib /</tt>
 
::::: lib /</tt>
 +
 +
When building a 64 bits version, use the following structure for the 3dparty tools:
 +
<tt>
 +
:: [ftp://ftp.ihg.uni-duisburg.de/FlightGear/Win32/MSVC/ 3rdParty.x64] / </tt> ( 64 bit version ) <tt>
 +
::: bin /
 +
::: include /
 +
::: lib /</tt>
  
 
If you do not use the recommended structure you will need to enter paths by hand. Source and build directories can be located anywhere.
 
If you do not use the recommended structure you will need to enter paths by hand. Source and build directories can be located anywhere.
Line 40: Line 43:
 
== Building ==
 
== Building ==
 
# Set up a work directory as described above.
 
# Set up a work directory as described above.
# Open the CMake gui.
+
# '''Building SimGear'''
# '''The following steps depend on the part you would like to build.''' The here mentioned steps are for FlightGear, but SimGear and TerraGear can be built via the same method (just remember to change the paths).
+
## Open the CMake gui.
# Set <tt>"Where is the source code"</tt> to wherever you put the FlightGear sources (from the released tarball or the git repository).
+
## Set <tt>"Where is the source code"</tt> to wherever you put the SimGear sources (from the released tarball or the git repository).
# Set <tt>"Where to build the binaries"</tt> to an empty directory.
+
## Set <tt>"Where to build the binaries"</tt> to an empty directory.
# Press the <tt>"Configure"</tt> button. The first time that the project is configured, CMake will bring up a window asking which compiler you wish to use. Normally just accept CMakes suggestion, and press Finish. CMake will now do a check on your system and will produce a preliminary build configuration.
+
## Press the <tt>"Configure"</tt> button. The first time that the project is configured, CMake will bring up a window asking which compiler you wish to use. Normally just accept CMakes suggestion, and press Finish. CMake will now do a check on your system and will produce a preliminary build configuration.
# CMake adds new configuration variables in red. Some have a value ending with <tt>-NOTFOUND</tt>. These variables should receive your attention. Some errors will prevent FlightGear to build and others will simply invalidate some options without provoking build errors. First check the <tt>MSVC_3RDPARTY_ROOT</tt> variable. If it is not set, chances are that there will be a lot of <tt>-NOTFOUND</tt> errors. Instead of trying to fix every error individually, set that variable and press the <tt>"Configure"</tt> button again.
+
## CMake adds new configuration variables in red. Some have a value ending with <tt>-NOTFOUND</tt>. These variables should receive your attention. Some errors will prevent SimGear to build and others will simply invalidate some options without provoking build errors.  
# Also check the lines with a checkbox. These are build options and may impact the feature set of the built program.
+
### First check the <tt>MSVC_3RDPARTY_ROOT</tt> variable. If it is not set, chances are that there will be a lot of <tt>-NOTFOUND</tt> errors. Instead of trying to fix every error individually, set that variable to the location of the directory structure that is presented above. Then press the <tt>"Configure"</tt> button again.
# Change the <tt>CMAKE_INSTALL_PREFIX</tt> to <tt>${MSVC_3RDPARTY_ROOT}/install/msvc100/FlightGear</tt> because <tt>C:\Program Files</tt> is likely unwritable to ordinary Windows users and will integrate better with the above directory structure (this is mandatory for SimGear if you don't want to solve errors by hand).
+
### Also check the lines with a checkbox. These are build options and may impact the feature set of the built program.
# Repeat the process until the <tt>"Generate"</tt> button is enabled.
+
### Change the <tt>CMAKE_INSTALL_PREFIX</tt> to <tt>${MSVC_3RDPARTY_ROOT}/install/msvc100/SimGear</tt> because <tt>C:/Program Files</tt> is likely unwritable to ordinary Windows users and will integrate better with the above directory structure (this is mandatory for SimGear if you don't want to solve errors by hand).
# Press the <tt>"Generate"</tt> button.
+
## Repeat the process from step 5, until the <tt>"Generate"</tt> button is enabled.
# Start Visual Studio 2010 and load the FlightGear solution (FlightGear.sln) located in <tt>"Where to build the binaries"</tt> (point 4.)
+
## Press the <tt>"Generate"</tt> button.
# Choose the <tt>"Release"</tt> build in the VS2010 "Generation" toolbar[[File:MVSC 2010 solution.png|right]]
+
## Start Visual Studio 2010 and load the SimGear solution (SimGear.sln) located in <tt>"Where to build the binaries"</tt> (point 4.)
# Generate the solution.
+
## Choose the <tt>"Release"</tt> build in the VS2010 "Generation" toolbar[[File:MVSC 2010 solution.png|right]]
# If there are build errors, return to CMake, clear remaining errors, <tt>"Configure"</tt> and <tt>"Generate"</tt>
+
## Generate the solution.
# When Visual Studio is able to build everything without errors, build the <tt>INSTALL</tt> project to put the product files in <tt>${CMAKE_INSTALL_PREFIX}</tt>
+
## If there are build errors, return to CMake, clear remaining errors, <tt>"Configure"</tt> and <tt>"Generate"</tt>
 +
## When Visual Studio is able to build everything without errors, build the <tt>INSTALL</tt> project to put the product files in <tt>${CMAKE_INSTALL_PREFIX}</tt>
 +
# '''Building FlightGear'''
 +
#: Repeat the steps under Building Simgear, but change the <tt>SimGear</tt> paths to <tt>FlightGear</tt>.
 
# Enjoy!
 
# Enjoy!
  
PS: When updating the source from git, it is usually unnecessary to restart CMake as the solution is able to reconfigure itself when CMake files are changed. Simply rebuild the solution from Visual Studio and accept the reload of updated projects. It is also possible to edit CMakeList.txt files directly in Visual Studio as they also appear in the solution, and projects will be reconfigured on the next generation. To change build options or directory path, it is mandatory to use the CMake Gui. In case of problems, locate the <tt>CMakeCache.txt</tt> file in <tt>"Where to build the binaries”</tt> directory and delete it to reconfigure from scratch or use the menu item File->Delete Cache.
+
=== Updating ===
 +
When updating the source from [[git]], it is usually unnecessary to restart CMake as the solution is able to reconfigure itself when CMake files are changed. Simply rebuild the solution from Visual Studio and accept the reload of updated projects.  
 +
 
 +
It is also possible to edit CMakeList.txt files directly in Visual Studio as they also appear in the solution, and projects will be reconfigured on the next generation. To change build options or directory path, it is mandatory to use the CMake Gui. In case of problems, locate the <tt>CMakeCache.txt</tt> file in <tt>"Where to build the binaries”</tt> directory and delete it to reconfigure from scratch or use the menu item <tt>File > Delete Cache</tt>.
 +
 
 +
=== TerraGear ===
 +
TerraGear can be built the same way as FlightGear, just change the paths to your TerraGear source and directories.
  
 
== Jenkins Windows configurations ==
 
== Jenkins Windows configurations ==

Revision as of 19:07, 27 April 2012

1rightarrow.png See Building Flightgear for the main article about this subject.

Required software

Directory tree

On Windows, assumptions on the directory structure are made to automate the discovery of dependencies.

This recommended directory structure is described below. Clicking the links allows you to download pre-built parts (for 3rdParty, make sure to download the right bits version. You need only one of the zips.).

${MSVC_3RDPARTY_ROOT} /
3rdParty / ( includes plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ... )
bin /
include /
lib /
boost_1_44_0 /
boost /
install /
msvc100 / ( for VS2010 32 bits, or msvc90, msvc90-64 or msvc100-64 for VS2008 32, VS2008 64 and VS2010 64 )
OpenSceneGraph / ( OSG CMake install )
bin /
include /
lib /
SimGear /
include /
lib /

When building a 64 bits version, use the following structure for the 3dparty tools:

3rdParty.x64 / ( 64 bit version )
bin /
include /
lib /

If you do not use the recommended structure you will need to enter paths by hand. Source and build directories can be located anywhere.

The suggested inputs to cmake are :

     MSVC_3RDPARTY_ROOT : location of the above directory structure
     CMAKE_INSTALL_PREFIX : ${MSVC_3RDPARTY_ROOT}/install/msvc100/FlightGear (or any variation for the compiler version described above )

Building

  1. Set up a work directory as described above.
  2. Building SimGear
    1. Open the CMake gui.
    2. Set "Where is the source code" to wherever you put the SimGear sources (from the released tarball or the git repository).
    3. Set "Where to build the binaries" to an empty directory.
    4. Press the "Configure" button. The first time that the project is configured, CMake will bring up a window asking which compiler you wish to use. Normally just accept CMakes suggestion, and press Finish. CMake will now do a check on your system and will produce a preliminary build configuration.
    5. CMake adds new configuration variables in red. Some have a value ending with -NOTFOUND. These variables should receive your attention. Some errors will prevent SimGear to build and others will simply invalidate some options without provoking build errors.
      1. First check the MSVC_3RDPARTY_ROOT variable. If it is not set, chances are that there will be a lot of -NOTFOUND errors. Instead of trying to fix every error individually, set that variable to the location of the directory structure that is presented above. Then press the "Configure" button again.
      2. Also check the lines with a checkbox. These are build options and may impact the feature set of the built program.
      3. Change the CMAKE_INSTALL_PREFIX to ${MSVC_3RDPARTY_ROOT}/install/msvc100/SimGear because C:/Program Files is likely unwritable to ordinary Windows users and will integrate better with the above directory structure (this is mandatory for SimGear if you don't want to solve errors by hand).
    6. Repeat the process from step 5, until the "Generate" button is enabled.
    7. Press the "Generate" button.
    8. Start Visual Studio 2010 and load the SimGear solution (SimGear.sln) located in "Where to build the binaries" (point 4.)
    9. Choose the "Release" build in the VS2010 "Generation" toolbar
      MVSC 2010 solution.png
    10. Generate the solution.
    11. If there are build errors, return to CMake, clear remaining errors, "Configure" and "Generate"
    12. When Visual Studio is able to build everything without errors, build the INSTALL project to put the product files in ${CMAKE_INSTALL_PREFIX}
  3. Building FlightGear
    Repeat the steps under Building Simgear, but change the SimGear paths to FlightGear.
  4. Enjoy!

Updating

When updating the source from git, it is usually unnecessary to restart CMake as the solution is able to reconfigure itself when CMake files are changed. Simply rebuild the solution from Visual Studio and accept the reload of updated projects.

It is also possible to edit CMakeList.txt files directly in Visual Studio as they also appear in the solution, and projects will be reconfigured on the next generation. To change build options or directory path, it is mandatory to use the CMake Gui. In case of problems, locate the CMakeCache.txt file in "Where to build the binaries” directory and delete it to reconfigure from scratch or use the menu item File > Delete Cache.

TerraGear

TerraGear can be built the same way as FlightGear, just change the paths to your TerraGear source and directories.

Jenkins Windows configurations

OSG-stable-Win

cmake ..\svn -G "Visual Studio 10"
      -DACTUAL_3RDPARTY_DIR:PATH=%WORKSPACE%/3rdParty
      -DBUILD_OSG_APPLICATIONS:BOOL=ON
      -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc100/OpenSceneGraph
      -DOSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS:BOOL=OFF
      -DFREETYPE_LIBRARY:FILEPATH=%WORKSPACE%/3rdParty/lib/freetype243.lib
      -DGDAL_INCLUDE_DIR:PATH=
      -DGDAL_LIBRARY:FILEPATH=

SimGear-Win-CMake

cmake ..\SimGear -G "Visual Studio 10"
      -DMSVC_3RDPARTY_ROOT=%WORKSPACE%
      -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc100/SimGear

FlightGear-Win-CMake

cmake ..\FlightGear -G "Visual Studio 10"
      -DMSVC_3RDPARTY_ROOT=%WORKSPACE%
      -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc100/FlightGear
      -DFLTK_FLUID_EXECUTABLE=%WORKSPACE%/3rdParty/bin/fluid.exe

FGRun-Win-CMake

cmake ..\svn -G "Visual Studio 10" 
      -DMSVC_3RDPARTY_ROOT:PATH=%WORKSPACE%
      -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc100/FGRun
      -DFLTK_FLUID_EXECUTABLE:FILEPATH=%WORKSPACE%/3rdParty/bin/fluid.exe
      -DGETTEXT_MSGFMT_EXECUTABLE:FILEPATH=%WORKSPACE%/3rdParty/bin/msgfmt.exe
      -DGETTEXT_MSGMERGE_EXECUTABLE:FILEPATH=%WORKSPACE%/3rdParty/bin/msgmerge.exe

TerraGear-Win-CMake

cmake ..\TerraGear -G "Visual Studio 10"
      -DMSVC_3RDPARTY_ROOT=%WORKSPACE%
      -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc100/TerraGear
      -DGPC_LIBRARY=%WORKSPACE%/3rdParty/lib/gpc232.lib
      -DNEWMAT_LIBRARY=%WORKSPACE%/3rdParty/lib/newmat11.lib

External link