User:Legoboyvdlp/Building using CMake - Windows: Difference between revisions

Jump to navigation Jump to search
Line 74: Line 74:
## Press [[File:CMake GUI Configure.png]]. The first time that the project is configured, CMake will bring up a window asking you to "Specify the generator for this project" i.e. which compiler you wish to use. Select Visual Studio 16 2019 (or the respective version for your own copy of Visual Studio), and press Finish. CMake will now do a check on your system and will produce a preliminary build configuration.
## Press [[File:CMake GUI Configure.png]]. The first time that the project is configured, CMake will bring up a window asking you to "Specify the generator for this project" i.e. which compiler you wish to use. Select Visual Studio 16 2019 (or the respective version for your own copy of Visual Studio), 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 do not necessarily need a value. Some errors will prevent SimGear from building and others will simply invalidate some options without causing build errors and thus can be ignored.
## CMake adds new configuration variables in red. Some have a value ending with <tt>-NOTFOUND</tt>. These variables do not necessarily need a value. Some errors will prevent SimGear from building and others will simply invalidate some options without causing build errors and thus can be ignored.
### 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 <tt>\Dependencies</tt> folder in the directory structure that is presented above. Then press [[File:CMake GUI Configure.png]] again.
### 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 <tt>\Dependencies</tt> folder in the directory structure that is presented above. Then press [[File:CMake GUI Configure.png]] again. [[File:BuildMSVC 3DPartyRoot.png|thumb|Demonstrates how to set 3d party root in CMAKE gui]]
### Set the  <tt>CMAKE_INSTALL_PREFIX</tt> variable to <tt>\Dependencies\install\msvc140-64\Simgear</tt>
### Set the  <tt>CMAKE_INSTALL_PREFIX</tt> variable to <tt>\install\Simgear</tt>
### Set the <tt>Boost_INCLUDE_DIR</tt> variable to <tt>\Dependencies</tt>
### Set the <tt>Boost_INCLUDE_DIR</tt> variable to <tt>\Dependencies</tt>
### To pick up Boost correctly, you must add a new Cache entry with name <tt>BOOST_ROOT</tt>, type <tt>PATH</tt>, and value <tt>\Dependencies</tt>. It is '''not''' required to set Boost_DIR to any value.
### To pick up Boost correctly, you must add a new Cache entry with name <tt>BOOST_ROOT</tt>, type <tt>PATH</tt>, and value <tt>\Dependencies</tt>. It is '''not''' required to set Boost_DIR to any value.
Line 87: Line 87:
## Generate the solution with F7 key or right-click the top level "Solution SimGear" in the Solution Explorer and choose Build. It should take ~20 minutes on average hardware.
## Generate the solution with F7 key or right-click the top level "Solution SimGear" in the Solution Explorer and choose Build. It should take ~20 minutes on average hardware.
## If there are build errors, return to CMake, clear remaining errors, [[File:CMake GUI Configure.png]] and [[File:CMake GUI Generate.png]].
## If there are build errors, return to CMake, clear remaining errors, [[File:CMake GUI Configure.png]] and [[File:CMake GUI Generate.png]].
## When Visual Studio is able to build everything without errors, right-click on the <tt>INSTALL</tt> project (further down within the "Solution Simgear" solution) and choose Build, which will put the include and lib files in <tt>${CMAKE_INSTALL_PREFIX}</tt>. This should only take a few seconds as you have already compiled everything.
## When Visual Studio is able to build everything without errors, right-click on the <tt>INSTALL</tt> project (further down within the "Solution Simgear" solution) and choose Build, which will put the include and lib files in <tt>${CMAKE_INSTALL_PREFIX}</tt>. This should only take a few seconds as you have already compiled everything. [[File:BuildInstallProjectMSVC.png|thumb|Demonstrates building INSTALL project in MSVC]]
# '''Building FlightGear'''
# '''Building FlightGear'''
#: Repeat the steps under Building Simgear, but change the <tt>SimGear</tt> paths to <tt>FlightGear</tt>.
#: Repeat the steps under Building Simgear, but change the <tt>SimGear</tt> paths to <tt>FlightGear</tt>.
## Notably, you will have to link Simgear and QT5 to CMAKE_PREFIX_PATH ''in addition to'' OSG (as with Simgear). To do this, insert the directory values with a semi-colon to separate them. for instance <tt>SGPATH;QT5PATH;OSGPATH</tt>.
## Set CMAKE_INSTALL_PREFIX to <tt>\install\FlightGear</tt>
### Simgear: <tt>\Dependencies\install\msvc140-64\Simgear</tt>
## Link Simgear to FlightGear using <tt>Simgear_DIR</tt>, pointing to <tt>\install\Simgear\lib\cmake\SimGear</tt> [[File:BuildSimgear DIR.png|thumb|Demonstrates how to link Simgear to FlightGear]]
## Notably, you will have to link QT5 to CMAKE_PREFIX_PATH ''in addition to'' OSG (as with Simgear). To do this, insert the directory values with a semi-colon to separate them. for instance <tt>QT5PATH;OSGPATH</tt>.
### QT5: <tt>C:/Qt/5.15.0/msvc2019_64</tt> (adjust to match your QT installation).
### QT5: <tt>C:/Qt/5.15.0/msvc2019_64</tt> (adjust to match your QT installation).
### My personal final path was: <tt>C:\Users\redpa\Documents\FlightGear\fg-from-scratch\fresh-build\Dependencies\install\msvc140-64\Simgear;C:/Users/redpa/Documents/FlightGear/fg-from-scratch/fresh-build/Dependencies/install/msvc140-64/OpenSceneGraph;C:/Qt/5.15.0/msvc2019_64</tt>
### My personal final path was: <tt>C:/Users/redpa/Documents/FlightGear/fg-from-scratch/fresh-build/Dependencies/install/msvc140 64/OpenSceneGraph;C:/Qt/5.15.0/msvc2019_64</tt>
# Enjoy!
# '''Post-compilation steps:'''
## Install QT5 using WinDeployQT: this program is contained within the QT installation. For me, I found it inside <tt>C:\Qt\5.15.0\msvc2019_64\bin</tt>. Run it in a cmd window, with the console options as required. This pulls in all the necessary QT files.
## Install .dlls:
### either manually copy in to the <tt>install/FlightGear/bin/</tt> folder
### or, preferrably, add the directories containing them to %PATH% environment variable.
#### Dependencies\3rdParty.x64\bin
#### Dependencies\install\msvc140-64\OpenSceneGraph\bin
## Enjoy!


=== Updating ===
=== Updating ===
842

edits

Navigation menu