From 5a64d51e1006481852b8f92da7e55f8a230bca60 Mon Sep 17 00:00:00 2001
From: James Turner <James Turner>
Date: Wed, 3 Aug 2016 10:39:32 +0100
Subject: [PATCH] Further Windows build fixes

Adjust OSG install location to match existing Jenkins setup.
---
 FlightGear.iss            | 30 +++++++++++++++++++++++++++---
 build_release_windows.bat | 16 ++++++++++++----
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/FlightGear.iss b/FlightGear.iss
index 9c2c200..68ed3dc 100755
--- a/FlightGear.iss
+++ b/FlightGear.iss
@@ -28,16 +28,18 @@
 
 #define VCInstallDir VSInstallDir + "\VC"
 #define InstallDir32 "X:\install\msvc140"
-#define OSGPluginsDir InstallDir32 + "\bin\osgPlugins-" + OSGVersion
+#define OSGInstallDir InstallDir32 + "\OpenSceneGraph"
+#define OSGPluginsDir OSGInstallDir + "\bin\osgPlugins-" + OSGVersion
 
 #define InstallDir64 "X:\install\msvc140-64"
-#define OSG64PluginsDir InstallDir64 + "\bin\osgPlugins-" + OSGVersion
+#define OSG64InstallDir InstallDir64 + "\OpenSceneGraph"
+#define OSG64PluginsDir OSG64InstallDir + "\bin\osgPlugins-" + OSGVersion
 
 #define ThirdPartyDir "X:\windows-3rd-party\msvc140"
 
 ; we copy everything in install/<arch>/bin except these, which aren't
 ; useful to the end-user to ship
-#define ExcludedBinaries "*smooth.exe,metar.exe,js_demo.exe,osg*.exe,present3D.exe,osgPlugins-*,*Shadow.dll,*Terrain.dll,*osgUI.dll,*Animation.dll,*Manipulator.dll,*Presentation.dll"
+#define ExcludedBinaries "*smooth.exe,metar.exe,js_demo.exe"
 
 [Setup]
 AppId=FlightGear
@@ -114,6 +116,17 @@ Source: "X:\fgdata\*.*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubd
 #endif
 
 ; 32 bits install
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osg.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgDB.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgGA.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgParticle.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgText.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgUtil.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgViewer.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgSim.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\osg{#OSGSoNumber}-osgFX.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+Source: "{#OSGInstallDir}\bin\ot{#OTSoNumber}-OpenThreads.dll"; DestDir: "{app}\bin"; Check: not Is64BitInstallMode
+
 Source: "{#OSGPluginsDir}\osgdb_ac.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Check: not Is64BitInstallMode
 Source: "{#OSGPluginsDir}\osgdb_osg.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Check: not Is64BitInstallMode
 Source: "{#OSGPluginsDir}\osgdb_osga.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Check: not Is64BitInstallMode
@@ -140,6 +153,17 @@ Source: "{#OSGPluginsDir}\osgdb_deprecated_osg.dll"; DestDir: "{app}\bin\osgPlug
 Source: "{#OSGPluginsDir}\osgdb_deprecated_osgparticle.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Check: not Is64BitInstallMode
 
 ; 64 bits install
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osg.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgDB.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgGA.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgParticle.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgText.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgUtil.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgViewer.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgSim.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\osg{#OSGSoNumber}-osgFX.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+Source: "{#OSG64InstallDir}\bin\ot{#OTSoNumber}-OpenThreads.dll"; DestDir: "{app}\bin"; Check: Is64BitInstallMode
+
 Source: "{#OSG64PluginsDir}\osgdb_ac.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Flags: skipifsourcedoesntexist; Check: Is64BitInstallMode
 Source: "{#OSG64PluginsDir}\osgdb_osg.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Flags: skipifsourcedoesntexist; Check: Is64BitInstallMode
 Source: "{#OSG64PluginsDir}\osgdb_osga.dll"; DestDir: "{app}\bin\osgPlugins-{#OSGVersion}"; Flags: skipifsourcedoesntexist; Check: Is64BitInstallMode
diff --git a/build_release_windows.bat b/build_release_windows.bat
index 209342c..4db271a 100755
--- a/build_release_windows.bat
+++ b/build_release_windows.bat
@@ -2,11 +2,14 @@
 IF NOT DEFINED WORKSPACE SET WORKSPACE=%~dp0
 
 REM following are for testing the script locally
-REM SET PATH=%PATH%;C:\"Program Files"\CMake\bin;C:\"Program Files (x86)\Inno Setup 5"\
+REM SET PATH=%PATH%;%ProgramFiles%\CMake\bin;%ProgramFiles(x86)%\"Inno Setup 5"\
 REM SET QT5SDK32=C:\Qt\5.6\msvc2015
 REM SET QT5SDK64=C:\Qt\5.6\msvc2015_64
 REM SET IS_NIGHTLY_BUILD=1
 
+SET OSG32=%WORKSPACE%\install\msvc140\OpenSceneGraph
+SET OSG64=%WORKSPACE%\install\msvc140-64\OpenSceneGraph
+
 REM 32bits
 md build-sg32
 md build-fg32
@@ -15,6 +18,7 @@ cd build-sg32
 cmake ..\simgear -G "Visual Studio 14" ^
                  -DMSVC_3RDPARTY_ROOT=%WORKSPACE%/windows-3rd-party/msvc140 ^
                  -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
+                 -DCMAKE_PREFIX_PATH:PATH=%OSG32% ^
                  -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140
 cmake --build . --config Release --target INSTALL
 
@@ -22,14 +26,16 @@ cd ..\build-fg32
 cmake ..\flightgear -G "Visual Studio 14" ^
                     -DMSVC_3RDPARTY_ROOT=%WORKSPACE%/windows-3rd-party/msvc140 ^
                     -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140 ^
+                    -DCMAKE_PREFIX_PATH:PATH=%WORKSPACE%/install/msvc140/OpenSceneGraph ^
                     -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
-                    -DCMAKE_PREFIX_PATH=%QT5SDK32%
+                    -DCMAKE_PREFIX_PATH=%QT5SDK32%;%OSG32%
 cmake --build . --config Release --target INSTALL
 
 cd ..\build-fgrun32
 cmake ..\fgrun -G "Visual Studio 14" ^
                -DMSVC_3RDPARTY_ROOT:PATH=%WORKSPACE%/windows-3rd-party/msvc140 ^
                -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
+               -DCMAKE_PREFIX_PATH:PATH=%OSG32% ^
                -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140
 cmake --build . --config Release --target INSTALL
 
@@ -43,6 +49,7 @@ cd build-sg64
 cmake ..\SimGear -G "Visual Studio 14 Win64" ^
                  -DMSVC_3RDPARTY_ROOT=%WORKSPACE%/windows-3rd-party/msvc140 ^
                  -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
+                 -DCMAKE_PREFIX_PATH:PATH=%OSG64% ^
                  -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140-64
 cmake --build . --config Release --target INSTALL
 
@@ -51,13 +58,14 @@ cmake ..\flightgear -G "Visual Studio 14 Win64" ^
                     -DMSVC_3RDPARTY_ROOT=%WORKSPACE%/windows-3rd-party/msvc140 ^
                     -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
                     -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140-64 ^
-                    -DCMAKE_PREFIX_PATH=%QT5SDK64%
+                    -DCMAKE_PREFIX_PATH=%QT5SDK64%;%OSG64%
 cmake --build . --config Release --target INSTALL
 
 cd ..\build-fgrun64
 cmake ..\fgrun -G "Visual Studio 14 Win64" ^
                -DMSVC_3RDPARTY_ROOT=%WORKSPACE%/windows-3rd-party/msvc140 ^
                -DBOOST_ROOT=%WORKSPACE%/windows-3rd-party ^
+               -DCMAKE_PREFIX_PATH:PATH=%OSG64% ^
                -DCMAKE_INSTALL_PREFIX:PATH=%WORKSPACE%/install/msvc140-64
 
 cmake --build . --config Release --target INSTALL
@@ -82,7 +90,7 @@ copy %WORKSPACE%\build-fg32\src\Main\RelWithDebInfo\fgfs.pdb %WORKSPACE%\Output\
 copy %WORKSPACE%\build-fg64\src\Main\RelWithDebInfo\fgfs.pdb %WORKSPACE%\Output\fgfs-x64-%BUILD_NUMBER%.pdb
 
 REM indirect way to get command output into an environment variable
-set PATH=%WORKSPACE%\install\msvc140\bin;%PATH%
+set PATH=%OSG32%\bin;%PATH%
 osgversion --so-number > %TEMP%\osg-so-number.txt
 osgversion --version-number > %TEMP%\osg-version.txt
 osgversion --openthreads-soversion-number > %TEMP%\openthreads-so-number.txt