OpenSceneGraph 3.0: Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action—building with a Visual Studio solution

There are only two steps left in order to build the Visual Studio solution and create your own OSG packages, which will include runtime binaries, headers, static-link libraries, utilities, and examples.

  1. First, select a build type (Debug, Release, RelWithDebInfo, or MinSizeRel), and build the ALL_BUILD project. This may take an extremely long time during first-time building, but will save a lot of time in subsequent compilations, unless you have cleared all intermediate files and decided to rebuild the solution completely from scratch.
  2. When the building process has finished, switch to the INSTALL project and "build" it. The compiler will traverse a series of post-build events that install all of the built files into the directory defined by the CMAKE_INSTALL_PREFIX option.
    Time for action—building with a Visual Studio solution

What just happened?

Everything is done as if you are working on your own Visual Studio solutions! The only difference is that every subproject will include an extra CMakeLists.txt file, which will check if the source files or settings were modified in the pre-build step, and automatically regenerate the project if necessary.

Go to your installation directory to see if all of the necessary files are already there. Then run the osgversion and osgviewer commands in the binary directory to see if the new package performs correctly. Do not forget to hide or uninstall the prebuilt packages generated by the quick installer in order to avoid any confusion caused by the coexistence of more than one binary package.

Please note that, when using Debug build type, the installed filename will have a postfix, of d. For example, osgviewer.exe will be renamed to osgviewerd.exe, to be distinct from the Release distribution. This behavior can be changed by setting the CMAKE_DEBUG_POSTFIX option and re-configuring the solution.

Pop quiz—the difference between ALL_BUILD and 'build all'

Some developers may love the following steps for building their Visual Studio solutions: open the Batch Build dialog box, select all projects in the current solution for inclusion in the batch build, start the build process, and go and have a cup of coffee (maybe more). Do you think this will produce the same result as using ALL_BUILD and then the INSTALL project? Will they take the same time?