1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-28 00:15:06 +00:00

MSVC: extern/ tweaks to make it build

Not everything is supported but it does build with the following CMakeSettings.json
variables and dependencies from vcpkg:

      "variables": [
        { "name": "OPENMW_USE_SYSTEM_BULLET", "value": "False", "type": "BOOL" },
        { "name": "OPENMW_USE_SYSTEM_MYGUI", "value": "False", "type": "BOOL" },
        { "name": "OPENMW_USE_SYSTEM_OSG", "value": "False", "type": "BOOL" },
        { "name": "BULLET_STATIC", "value": "True", "type": "BOOL" },
        { "name": "OSG_STATIC", "value": "False", "type": "BOOL" },
        { "name": "MYGUI_STATIC", "value": "False", "type": "BOOL" }
      ],

What works: it builds

What does not work: Not all DLLs are copied into the output directory with this set up
(SDL2, MyGUI, Bullet, OSG, are not copied).
This commit is contained in:
Gleb Mazovetskiy 2021-03-16 02:56:33 +00:00
parent 70f48d9b26
commit 493659d4f9
2 changed files with 43 additions and 6 deletions

View File

@ -115,6 +115,12 @@ 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)
if(OPENMW_USE_SYSTEM_BULLET)
set(_bullet_static_default OFF)
else()
set(_bullet_static_default ON)
endif()
option(BULLET_STATIC "Link static build of Bullet into the binaries" ${_bullet_static_default})
option(OPENMW_USE_SYSTEM_OSG "Use system provided OpenSceneGraph libraries" ON)
if(OPENMW_USE_SYSTEM_OSG)

43
extern/CMakeLists.txt vendored
View File

@ -31,6 +31,15 @@ if(NOT OPENMW_USE_SYSTEM_BULLET)
set(USE_DOUBLE_PRECISION ${BULLET_USE_DOUBLES} CACHE BOOL "")
set(BULLET2_MULTITHREADING ON CACHE BOOL "")
if(BULLET_STATIC)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
else()
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
if(MSVC)
set(USE_MSVC_RUNTIME_LIBRARY_DLL ON CACHE BOOL "" FORCE)
endif()
endif()
# master on 12 Mar 2021
include(FetchContent)
FetchContent_Declare(bullet
@ -61,9 +70,9 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI)
set(MYGUI_DONT_USE_OBSOLETE OFF CACHE BOOL "")
if(MYGUI_STATIC)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
else()
set(BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
endif()
include(FetchContent)
@ -81,8 +90,6 @@ endif()
if(NOT OPENMW_USE_SYSTEM_OSG)
cmake_minimum_required(VERSION 3.11) # for FetchContent
set(DYNAMIC_OPENTHREADS OFF CACHE BOOL "")
set(DYNAMIC_OPENSCENEGRAPH OFF CACHE BOOL "")
set(BUILD_OSG_APPLICATIONS OFF CACHE BOOL "")
set(BUILD_OSG_DEPRECATED_SERIALIZERS OFF CACHE BOOL "")
set(OSG_FIND_3RD_PARTY_DEPS OFF CACHE BOOL "")
@ -104,9 +111,33 @@ if(NOT OPENMW_USE_SYSTEM_OSG)
set(OPENGL_PROFILE "GL2" CACHE STRING "")
if(OSG_STATIC)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(DYNAMIC_OPENTHREADS OFF CACHE BOOL "" FORCE)
set(DYNAMIC_OPENSCENEGRAPH OFF CACHE BOOL "" FORCE)
else()
set(BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
set(DYNAMIC_OPENTHREADS ON CACHE BOOL "" FORCE)
set(DYNAMIC_OPENSCENEGRAPH ON CACHE BOOL "" FORCE)
endif()
mark_as_advanced(DYNAMIC_OPENTHREADS DYNAMIC_OPENSCENEGRAPH)
if(WIN32)
# OSG here inherits C++17 language level because it doesn't specify its own.
#
# OSG's `using namespace std` interferes with Windows header files.
#
# See https://developercommunity.visualstudio.com/t/error-c2872-byte-ambiguous-symbol/93889
#
# An alternative way to work around this without changing the language level is:
#
# add_compile_definitions(_HAS_STD_BYTE=0)
#
# TODO: Put OSG into its own scope so that this does not leak into Recast below.
set(CMAKE_CXX_STANDARD 11)
if(MSVC)
set(OSG_MSVC_VERSIONED_DLL OFF CACHE BOOL "")
endif()
endif()
# branch OpenSceneGraph-3.6 on 23 Jan 2021.