From 3d334dae754fdc67851812cc2ef5c2be8c8909fd Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Fri, 22 Jan 2021 21:33:07 +0000 Subject: [PATCH] Fix MYGUI/OSG_STATIC and BUILD_SHARED_LIBS --- CMakeLists.txt | 20 ++++++++++++-------- extern/CMakeLists.txt | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc0d1b32c..5ba48c01d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,19 +109,23 @@ 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(QT_STATIC "Link static build of QT into the binaries" FALSE) +option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON) + option(OPENMW_USE_SYSTEM_OSG "Use system provided OpenSceneGraph libraries" ON) -option(OSG_STATIC "Link static build of OpenSceneGraph into the binaries" OFF) -if(NOT OPENMW_USE_SYSTEM_OSG) - set(OSG_STATIC ON CACHE BOOL "") +if(OPENMW_USE_SYSTEM_OSG) + set(_osg_static_default OFF) +else() + set(_osg_static_default ON) endif() - -option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON) +option(OSG_STATIC "Link static build of OpenSceneGraph into the binaries" ${_osg_static_default}) option(OPENMW_USE_SYSTEM_MYGUI "Use system provided mygui library" ON) -option(MYGUI_STATIC "Link static build of Mygui into the binaries" OFF) -if(NOT OPENMW_USE_SYSTEM_MYGUI) - set(MYGUI_STATIC ON CACHE BOOL "") +if(OPENMW_USE_SYSTEM_MYGUI) + set(_mygui_static_default OFF) +else() + set(_mygui_static_default ON) endif() +option(MYGUI_STATIC "Link static build of Mygui into the binaries" ${_mygui_static_default}) option(OPENMW_UNITY_BUILD "Use fewer compilation units to speed up compile time" FALSE) option(OPENMW_LTO_BUILD "Build OpenMW with Link-Time Optimization (Needs ~2GB of RAM)" OFF) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index de2f80ddf..a8e741bd9 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -60,13 +60,18 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI) set(MYGUI_BUILD_PLUGINS OFF CACHE BOOL "") set(MYGUI_BUILD_TOOLS OFF CACHE BOOL "") + if(MYGUI_STATIC) + set(BUILD_SHARED_LIBS OFF) + else() + set(BUILD_SHARED_LIBS ON) + endif() + include(FetchContent) FetchContent_Declare(mygui URL https://github.com/MyGUI/mygui/archive/MyGUI3.4.0.zip URL_HASH MD5=9e990a4240430cbf567bfe73488a274e SOURCE_DIR fetched/mygui ) - set(BUILD_SHARED_LIBS ${MYGUI_STATIC}) FetchContent_MakeAvailableExcludeFromAll(mygui) set(MyGUI_INCLUDE_DIRS ${mygui_SOURCE_DIR}/MyGUIEngine/include PARENT_SCOPE) @@ -98,6 +103,12 @@ if(NOT OPENMW_USE_SYSTEM_OSG) set(OPENGL_PROFILE "GL2" CACHE STRING "") + if(OSG_STATIC) + set(BUILD_SHARED_LIBS OFF) + else() + set(BUILD_SHARED_LIBS ON) + endif() + # branch OpenSceneGraph-3.6 on 18 Jan 2021. # + https://github.com/openscenegraph/OpenSceneGraph/pull/1032 # + https://github.com/openscenegraph/OpenSceneGraph/pull/1033 @@ -108,7 +119,6 @@ if(NOT OPENMW_USE_SYSTEM_OSG) URL_HASH MD5=d67088aeb976486287343c1287b56ba3 SOURCE_DIR fetched/osg ) - set(BUILD_SHARED_LIBS ${OSG_STATIC}) FetchContent_MakeAvailableExcludeFromAll(osg) set(OPENSCENEGRAPH_INCLUDE_DIRS ${osg_SOURCE_DIR}/include ${osg_BINARY_DIR}/include PARENT_SCOPE)