]> git.mxchange.org Git - flightgear.git/blobdiff - README.cmake
#561: keep magnetic heading within limits when mag-variation is negative
[flightgear.git] / README.cmake
index ede3b994ca66527fbf7323e980d269ebffca4d12..f03333f5b007e94c0740172f30cdab5c5f235b1a 100644 (file)
@@ -1,5 +1,7 @@
 Getting started with CMake
 
+[Windows instructions at the end of this document]
+
 (These instructions apply to Unix-like systems, including Cygwin and Mac. To
 build using Visual Studio or some other IDE supported by CMake, most of the
 information below still applies)
@@ -8,7 +10,7 @@ Always compile in a separate directory to the code. For example, if the
 code (eg, from Git) is at /home/curt/projects/flightgear, you might create
 /home/curt/projects/fgbuild. Change into the new directory, and run
 
-    cmake ../flightger
+    cmake ../flightgear
     
 To generate standard Unix Makefiles in fgbuild.
 
@@ -20,9 +22,19 @@ Note the install prefix is automatically searched for required libraries
 and header files, so if you install PLIB, OpenSceneGraph and SimGear to the
 same prefix, most configuration options are unnecessary.
 
-To specify that a particular dependency is in a non-standard location, most
-libraries support an environment variable - eg PLIBDIR or OSG_ROOT - to
-allow precise selection.
+If for some reason you have a dependency (or several) at a different prefix,
+you can specify one or more via CMAKE_PREFIX_PATH:
+
+    cmake ../flightgear -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs"
+
+(note the use of semi-colons to specify multiple prefix paths)
+
+Standard prefixes are searched automatically (/usr, /usr/local, /opt/local)
+
+Most dependencies also expose an environment variable to specify their
+installation directory explicitly eg OSG_DIR or PLIBDIR. Any of the methods
+described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is
+usually simpler.
 
 By default, we select a release build. To create a debug build, use
 
@@ -34,7 +46,8 @@ Debug builds will automatically use corresponding debug builds of required
 libraries, if they are available. For example you can install debug builds of
 SimGear and OpenSceneGraph, and a debug FlightGear build will use them.
 
-(Debug builds of libraries have the 'd' suffix by default)
+(Debug builds of libraries have the 'd' suffix by default - Release builds
+have no additional suffix)
 
 Note most IDE projects (eg Xcode and Visual Studio) support building all the
 build types from the same project, so you can omit the CMAKE_BUILD_TYPE option
@@ -51,11 +64,19 @@ configurations, eg
 
 To set an optional feature, do
 
-    cmake ../flightgear -DFEATURE_NAME=ON
+    cmake ../flightgear -DFEATURE_NAME=ON 
+
+(or 'OFF' to disable )
+
+To see the variables that can be configured / are currently defined, you can
+run one of the GUI front ends, or the following command:
+
+    cmake ../flighgear -L
+
+Add 'A' to see all the options (including advanced options), or 'H' to see
+the help for each option (similar to running configure --help under autoconf):
 
-The easiest way to see the features that can be configured, is by running one
-of the cmake GUIs - either ncurses or graphical. You can also check the root
-CMakeLists.txt file.
+    cmake ../flightgear -LH
 
 Build Targets
 
@@ -100,8 +121,9 @@ You can set a property on an individual source file:
 Detecting Features / Libraries
 
 For most standard libraries (Gtk, wxWidget, Python, GDAL, Qt, libXml, Boost),
-cmake provides a standard helper. Check your cmake 'modules' directory to see
-the extensive list. 
+cmake provides a standard helper. To see the available modules, run:
+
+     cmake --help-module-list
 
 In the root CMakeLists file, use a statement like:
 
@@ -113,7 +135,8 @@ might have different names (eg, OPENSCENEGRAPH_LIBRARIES).
 
 If there's no standard helper for a library you need, find a similar one, copy
 it to CMakeModules/FindABC.cmake, and modify the code to fit. Generally this
-is pretty straightforward.
+is pretty straightforward. The built-in modules reside in the Cmake 'share'
+directory, eg /usr/share/cmake/modules on Unix systems.
 
 Note libraries support by pkg-config can be handled directly, with no need
 to create a custom FindABC helper.
@@ -132,3 +155,71 @@ If you add an additional line
     
 Then running 'make test' will run your executable as a unit test. The
 executable should return either a success or failure result code.
+
+
+
+SPECIAL INSTRUCTIONS TO BUILD UNDER WINDOWS WITH VISUAL STUDIO
+==============================================================
+
+On Windows, assumptions on the directory structure are made to automate the discovery of dependencies.
+This recommended directory structure is described below:
+
+${MSVC_3RDPARTY_ROOT} /
+      3rdParty /                 ( includes plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ...
+         bin /
+         include /
+         lib /
+      3rdParty.x64 /             ( 64 bit version )
+         ...
+      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 /
+
+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 )
+
+
+1. Set up a work directory as described above.
+
+2. Open the Cmake gui.
+
+3. Set "Where is the source code" to wherever you put the FlightGear sources (from the released tarball or the git repository).
+
+4. Set "Where to build the binaries" to an empty directory.
+
+5. 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.
+
+6. Cmake adds new configuration variables in red. Some have a value ending with -NOTFOUND. 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 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 and press the "Configure" button again.
+
+7. Also check the lines with a checkbox. These are build options and may impact the feature set of the built program.
+
+8. Change the CMAKE_INSTALL_PREFIX to ${MSVC_3RDPARTY_ROOT}/install/msvc100/FlightGear 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).
+
+10. Repeat the process until the "Generate" button is enabled.
+
+11. Press the "Generate" button.
+
+12. Start Visual Studio 2010 and load the FlightGear solution (FlightGear.sln) located in "Where to build the binaries" (point 4.)
+
+13. Choose the "Release" build in the VS2010 "Generation" toolbar
+
+14. Generate the solution.
+
+15. If there are build errors, return to Cmake, clear remaining errors, "Configure" and "Generate"
+
+16. When Visual Studio is able to build everything without errors, build the INSTALL project to put the product files in ${CMAKE_INSTALL_PREFIX}
+
+17. 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 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 in "Where to build the binaries\94 directory and delete it to reconfigure from scratch or use the menu item File->Delete Cache.