Skip to content

Instantly share code, notes, and snippets.

@battleguard
Last active October 30, 2015 19:50
Show Gist options
  • Select an option

  • Save battleguard/8b85340d51e8fa719172 to your computer and use it in GitHub Desktop.

Select an option

Save battleguard/8b85340d51e8fa719172 to your computer and use it in GitHub Desktop.
Automated script for building osgearth and osg for visual studio
steps to build
1. download VS2013 3rd Party full or small for OSG from OSG's website (http://www.openscenegraph.org/index.php/download-section/dependencies)
2. download OSG's source (https://github.com/openscenegraph/osg)
3. download OsgEarth source (https://github.com/gwaldron/osgearth)
4. extract them all and setup directory structure as such (you can change this setup by modifying the envvars, but this is the default way)
- osgEarthinstallfolder
-- 3rdParty_x86_x64
-- osg
-- osgearth
5. change the env-variables.bat to where these directorys are.
---- Note make sure 3rd party points to the x64 third party
example setup
set INSTALL_DIR=C:\test\Install
set THIRD_PARTY=C:\test\3rdParty_x86_x64\x64
set OSG_SOLUTION=C:\test\osg
set OSG_EARTH_SOLUTION=C:\test\osgearth
5b. make sure to go through each environment variable and read the comment to make sure it is correct on your machine.
6. run build-all.bat (this will take about an hour or longer)
call env-variables.bat
echo | build-osg.bat
echo | build-osgearth.bat
PAUSE
@echo on
call env-variables.bat
:: variables of where things are going
set SOLUTION_DIR=%OSG_SOLUTION%
set BUILD_DIR=%OSG_SOLUTION%\Build
set INSTALL_DIR=%INSTALL_DIR%
set THIRD_PARTY_DIR=%THIRD_PARTY%
mkdir %BUILD_DIR%
mkdir %INSTALL_DIR%
::copy OSG's 3rdParty elements into the output directory
ROBOCOPY "%THIRD_PARTY_DIR%" /E "%INSTALL_DIR%"
cd %BUILD_DIR%
%CMAKE_EXE% -G %VISUAL_STUDIO_VERSION% -D CMAKE_INSTALL_PREFIX:PATH="%INSTALL_DIR%" -D ACTUAL_3RDPARTY_DIR:PATH="%THIRD_PARTY_DIR%" "%SOLUTION_DIR%"
%MSBUILD_EXE% ALL_BUILD.vcxproj /p:Configuration=%BUILD_VERSION% /m:%CORES_TO_USE% /p:BuildInParallel=true
%MSBUILD_EXE% INSTALL.vcxproj /p:Configuration=%BUILD_VERSION% /m:%CORES_TO_USE% /p:BuildInParallel=true
cd %~dp0
PAUSE
@echo off
call env-variables.bat
:: variables of where things are going
set SOLUTION_DIR=%OSG_EARTH_SOLUTION%
set BUILD_DIR=%OSG_EARTH_SOLUTION%\build
set INSTALL_DIR=%INSTALL_DIR%
set THIRD_PARTY_DIR=%INSTALL_DIR%
mkdir %BUILD_DIR%
cd %BUILD_DIR%
::run cmake to build solution file
%CMAKE_EXE% -G %VISUAL_STUDIO_VERSION% -D CMAKE_INSTALL_PREFIX:PATH="%INSTALL_DIR%" -D CMAKE_PREFIX_PATH:PATH="%THIRD_PARTY_DIR%" -D GDAL_LIBRARY="%INSTALL_DIR%\lib\gdal_i.lib" "%SOLUTION_DIR%"
%MSBUILD_EXE% ALL_BUILD.vcxproj /p:Configuration=%BUILD_VERSION% /m:%CORES_TO_USE% /p:BuildInParallel=true
%MSBUILD_EXE% INSTALL.vcxproj /p:Configuration=%BUILD_VERSION% /m:%CORES_TO_USE% /p:BuildInParallel=true
cd %~dp0
PAUSE
:: WARNING: MUST BE FULL PATHS IN ORDER TO WORK
::ROOT_DIR only need to be changed if you do not have this script in your base folder for the install
set ROOT_DIR=%~dp0
set INSTALL_DIR=%ROOT_DIR%Install\Release
set THIRD_PARTY=%ROOT_DIR%3rdParty_x86_x64\x64
set OSG_SOLUTION=%ROOT_DIR%osg
set OSG_EARTH_SOLUTION=%ROOT_DIR%osgearth
:: set to CMAKE location can be downloaded here (https://cmake.org/download/)
set CMAKE_EXE="%ProgramFiles(x86)%\cmake\bin\cmake.exe"
:: this will need to be changed if you are not using Visual Studio 2013
set MSBUILD_EXE="%ProgramFiles(x86)%\MSBuild\12.0\Bin\amd64\MSBuild.exe"
:: if you want it to use less resources you can manually set the number of cores
set CORES_TO_USE=%NUMBER_OF_PROCESSORS%
::Set to build either Debug/Release
set BUILD_VERSION=Debug
:: this will need to be changed if you are not using Visual Studio 2013
:: you can see all the visual studio version names by looking here (https://cmake.org/cmake/help/v3.4/manual/cmake-generators.7.html#visual-studio-generators)
set VISUAL_STUDIO_VERSION="Visual Studio 12 2013 Win64"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment