mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 02:26:41 +00:00 
			
		
		
		
	Merge pull request #667 from slothlife/static-deps-build
Add support for linking OpenSceneGraph statically and fixes for MyGUI and QT static linking
This commit is contained in:
		
						commit
						753d35b0de
					
				
					 4 changed files with 77 additions and 1 deletions
				
			
		| 
						 | 
					@ -56,6 +56,8 @@ configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_
 | 
				
			||||||
option(MYGUI_STATIC "Link static build of Mygui into the binaries" FALSE)
 | 
					option(MYGUI_STATIC "Link static build of Mygui into the binaries" FALSE)
 | 
				
			||||||
option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
 | 
					option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
 | 
				
			||||||
option(SDL2_STATIC "Link static build of SDL into the binaries" FALSE)
 | 
					option(SDL2_STATIC "Link static build of SDL into the binaries" FALSE)
 | 
				
			||||||
 | 
					option(OSG_STATIC "Link static build of OpenSceneGraph into the binaries" FALSE)
 | 
				
			||||||
 | 
					option(QT_STATIC "Link static build of QT into the binaries" FALSE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
option(OPENMW_UNITY_BUILD "Use fewer compilation units to speed up compile time" FALSE)
 | 
					option(OPENMW_UNITY_BUILD "Use fewer compilation units to speed up compile time" FALSE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -199,9 +201,67 @@ IF(BOOST_STATIC)
 | 
				
			||||||
    set(Boost_USE_STATIC_LIBS   ON)
 | 
					    set(Boost_USE_STATIC_LIBS   ON)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgGA osgAnimation osgParticle osgQt osgUtil osgFX)
 | 
					find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgQt osgUtil osgFX)
 | 
				
			||||||
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
 | 
					include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(OSG_STATIC)
 | 
				
			||||||
 | 
					   macro(use_static_osg_plugin_library PLUGIN_NAME)
 | 
				
			||||||
 | 
					      set(PLUGIN_NAME_DBG ${PLUGIN_NAME}d ${PLUGIN_NAME}D ${PLUGIN_NAME}_d ${PLUGIN_NAME}_D ${PLUGIN_NAME}_debug ${PLUGIN_NAME})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # For now, users wishing to do a static build will need to pass the path to where the plugins reside
 | 
				
			||||||
 | 
					      # More clever logic would need to deduce the path, probably installed under <OpenSceneGraph>/lib/osgPlugins-<X.X.X>
 | 
				
			||||||
 | 
					      find_library(${PLUGIN_NAME}_LIBRARY_REL NAMES ${PLUGIN_NAME} HINTS ${OSG_PLUGIN_LIB_SEARCH_PATH})
 | 
				
			||||||
 | 
					      find_library(${PLUGIN_NAME}_LIBRARY_DBG NAMES ${PLUGIN_NAME_DBG} HINTS ${OSG_PLUGIN_LIB_SEARCH_PATH})
 | 
				
			||||||
 | 
					      make_library_set(${PLUGIN_NAME}_LIBRARY)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if("${${PLUGIN_NAME}_LIBRARY}" STREQUAL "")
 | 
				
			||||||
 | 
					         message(FATAL_ERROR "Unable to find static OpenSceneGraph plugin: ${PLUGIN_NAME}")
 | 
				
			||||||
 | 
					      endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      set(OPENSCENEGRAPH_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES} ${${PLUGIN_NAME}_LIBRARY})
 | 
				
			||||||
 | 
					   endmacro()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   macro(use_static_osg_plugin_dep DEPENDENCY)
 | 
				
			||||||
 | 
					      find_package(${DEPENDENCY} REQUIRED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      set(OPENSCENEGRAPH_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES} ${${DEPENDENCY}_LIBRARIES})
 | 
				
			||||||
 | 
					   endmacro()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   add_definitions(-DOSG_LIBRARY_STATIC)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   set(PLUGIN_LIST
 | 
				
			||||||
 | 
					       osgdb_png # depends on libpng, zlib
 | 
				
			||||||
 | 
					       osgdb_tga
 | 
				
			||||||
 | 
					       osgdb_dds
 | 
				
			||||||
 | 
					       osgdb_jpeg # depends on libjpeg
 | 
				
			||||||
 | 
					       )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   foreach(PLUGIN ${PLUGIN_LIST})
 | 
				
			||||||
 | 
					      use_static_osg_plugin_library(${PLUGIN})
 | 
				
			||||||
 | 
					   endforeach()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   # OSG static plugins need to linked against their respective dependencies
 | 
				
			||||||
 | 
					   set(PLUGIN_DEPS_LIST
 | 
				
			||||||
 | 
					       PNG # needed by osgdb_png
 | 
				
			||||||
 | 
					       ZLIB # needed by osgdb_png
 | 
				
			||||||
 | 
					       JPEG # needed by osgdb_jpeg
 | 
				
			||||||
 | 
					       )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   foreach(DEPENDENCY ${PLUGIN_DEPS_LIST})
 | 
				
			||||||
 | 
					      use_static_osg_plugin_dep(${DEPENDENCY})
 | 
				
			||||||
 | 
					   endforeach()
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(QT_STATIC)
 | 
				
			||||||
 | 
					   if(WIN32)
 | 
				
			||||||
 | 
					      if(DESIRED_QT_VERSION MATCHES 4)
 | 
				
			||||||
 | 
					         # QtCore needs WSAAsyncSelect from Ws2_32.lib
 | 
				
			||||||
 | 
					         set(QT_QTCORE_LIBRARY ${QT_QTCORE_LIBRARY} Ws2_32.lib)
 | 
				
			||||||
 | 
					         message("QT_QTCORE_LIBRARY: ${QT_QTCORE_LIBRARY}")
 | 
				
			||||||
 | 
					      endif()
 | 
				
			||||||
 | 
					   endif()
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(MyGUI REQUIRED)
 | 
					find_package(MyGUI REQUIRED)
 | 
				
			||||||
if (${MYGUI_VERSION} VERSION_LESS "3.2.1")
 | 
					if (${MYGUI_VERSION} VERSION_LESS "3.2.1")
 | 
				
			||||||
    message(FATAL_ERROR "OpenMW requires MyGUI 3.2.1 or later, please install the latest version from http://mygui.info")
 | 
					    message(FATAL_ERROR "OpenMW requires MyGUI 3.2.1 or later, please install the latest version from http://mygui.info")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,7 @@ IF (WIN32) #Windows
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ( MYGUI_STATIC )
 | 
					        if ( MYGUI_STATIC )
 | 
				
			||||||
           set(LIB_SUFFIX "Static")
 | 
					           set(LIB_SUFFIX "Static")
 | 
				
			||||||
 | 
					           find_package(freetype)
 | 
				
			||||||
        endif ( MYGUI_STATIC )
 | 
					        endif ( MYGUI_STATIC )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        find_library ( MYGUI_LIBRARIES_REL NAMES MyGUIEngine${LIB_SUFFIX}.lib HINTS ${MYGUI_LIB_DIR} PATH_SUFFIXES "" release relwithdebinfo minsizerel )
 | 
					        find_library ( MYGUI_LIBRARIES_REL NAMES MyGUIEngine${LIB_SUFFIX}.lib HINTS ${MYGUI_LIB_DIR} PATH_SUFFIXES "" release relwithdebinfo minsizerel )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <components/vfs/manager.hpp>
 | 
					#include <components/vfs/manager.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef OSG_LIBRARY_STATIC
 | 
				
			||||||
 | 
					// This list of plugins should match with the list in the top-level CMakelists.txt.
 | 
				
			||||||
 | 
					USE_OSGPLUGIN(png)
 | 
				
			||||||
 | 
					USE_OSGPLUGIN(tga)
 | 
				
			||||||
 | 
					USE_OSGPLUGIN(dds)
 | 
				
			||||||
 | 
					USE_OSGPLUGIN(jpeg)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace
 | 
					namespace
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,9 +10,16 @@
 | 
				
			||||||
#include <osg/Geometry>
 | 
					#include <osg/Geometry>
 | 
				
			||||||
#include <osg/Texture2D>
 | 
					#include <osg/Texture2D>
 | 
				
			||||||
#include <osg/TexMat>
 | 
					#include <osg/TexMat>
 | 
				
			||||||
 | 
					#include <osgViewer/GraphicsWindow>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "imagetosurface.hpp"
 | 
					#include "imagetosurface.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef OSG_LIBRARY_STATIC
 | 
				
			||||||
 | 
					// Sets the default windowing system interface according to the OS.
 | 
				
			||||||
 | 
					// Necessary for OpenSceneGraph to do some things, like decompression.
 | 
				
			||||||
 | 
					USE_GRAPHICSWINDOW()
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace
 | 
					namespace
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue