1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 12:42:11 +00:00
OpenMW/apps/openmw/CMakeLists.txt
AnyOldName3 26be98966f Modernise Boost CMake stuff
Resolves https://gitlab.com/OpenMW/openmw/-/issues/8100

Also removes some old crud.
Hopefully the old crud is all:
* Handled automatically by CMake now we're using the modern approach.
* A hack-fix for a problem caused by not using the modern approach.
* Massively outdated so no longer necessary.

If it turns out this makes CI fail, I'll tweak things as necessary.

Changes that might not be wanted include:
* Getting rid of our BOOST_STATIC CMake option. In cases where the CMake config doesn't make the one correct choice from the build environment (i.e. because there's a choice) the CMake config exposes the option already.
  However, we were forcing this on for Windows, so that might matter.
  It seems to default to static on my machine even though I thought I read something suggesting otherwise, so we'll see how things go with that.
  If we eventually put CMake in charge of installing dependency DLLs this will be a moot point as we won't need to care.
* Bumping the minimum version of Boost to 1.70.0, as that's the first with working CMake config.
  It's from 2019, so plausibly there are distros too scared to use a library from five years ago as it can't legally drink in the US (although it could in limited quantities with parental supervision in the UK, as long as it's just something inconsequential like a single sip of beer).
2024-08-23 14:06:13 +01:00

258 lines
9.7 KiB
CMake

set(OPENMW_SOURCES
engine.cpp
options.cpp
)
set(OPENMW_RESOURCES
${CMAKE_SOURCE_DIR}/files/windows/openmw.rc
${CMAKE_SOURCE_DIR}/files/windows/openmw.exe.manifest
)
set(OPENMW_HEADERS
doc.hpp
engine.hpp
options.hpp
profile.hpp
)
source_group(apps/openmw FILES main.cpp android_main.cpp ${OPENMW_SOURCES} ${OPENMW_HEADERS} ${OPENMW_RESOURCES})
add_openmw_dir (mwrender
actors objects renderingmanager animation rotatecontroller sky skyutil npcanimation esm4npcanimation vismask
creatureanimation effectmanager util renderinginterface pathgrid rendermode weaponanimation screenshotmanager
bulletdebugdraw globalmap characterpreview camera localmap water terrainstorage ripplesimulation
renderbin actoranimation landmanager navmesh actorspaths recastmesh fogmanager objectpaging groundcover
postprocessor pingpongcull luminancecalculator pingpongcanvas transparentpass precipitationocclusion ripples
actorutil distortion animationpriority bonegroup blendmask animblendcontroller
)
add_openmw_dir (mwinput
actions actionmanager bindingsmanager controllermanager controlswitch
inputmanagerimp mousemanager keyboardmanager sensormanager gyromanager
)
add_openmw_dir (mwgui
layout textinput widgets race class birth review windowmanagerimp console dialogue
windowbase statswindow messagebox journalwindow charactercreation
mapwindow windowpinnablebase tooltips scrollwindow bookwindow resourceskin
formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog
enchantingdialog trainingwindow travelwindow exposedwindow cursor spellicons
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog
recharge mode videowidget backgroundimage itemwidget screenfader debugwindow spellmodel spellview
draganddrop timeadvancer jailscreen itemchargeview keyboardnavigation textcolours statswatcher
postprocessorhud settings
)
add_openmw_dir (mwdialogue
dialoguemanagerimp journalimp journalentry quest topic filter selectwrapper hypertextparser keywordsearch scripttest
)
add_openmw_dir (mwscript
locals scriptmanagerimp compilercontext interpretercontext cellextensions miscextensions
guiextensions soundextensions skyextensions statsextensions containerextensions
aiextensions controlextensions extensions globalscripts ref dialogueextensions
animationextensions transformationextensions consoleextensions userextensions
)
add_openmw_dir (mwlua
luamanagerimp object objectlists userdataserializer luaevents engineevents objectvariant
context menuscripts globalscripts localscripts playerscripts luabindings objectbindings cellbindings
mwscriptbindings camerabindings vfsbindings uibindings soundbindings inputbindings nearbybindings dialoguebindings
postprocessingbindings stats recordstore debugbindings corebindings worldbindings worker magicbindings factionbindings
classbindings itemdata inputprocessor animationbindings birthsignbindings racebindings markupbindings
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc
types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus
types/potion types/ingredient types/misc types/repair types/armor types/light types/static
types/clothing types/levelledlist types/terminal
)
add_openmw_dir (mwsound
soundmanagerimp openal_output ffmpeg_decoder sound sound_buffer sound_decoder sound_output
loudness movieaudiofactory alext efx efx-presets regionsoundselector watersoundupdater
)
add_openmw_dir (mwworld
refdata worldimp scene globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellvisitors failedaction
worldmodel localscripts customdata inventorystore ptr actionopen actionread actionharvest
actionequip timestamp actionalchemy cellstore actionapply actioneat
store esmstore fallback actionrepair actionsoulgem livecellref actiondoor
contentloader esmloader actiontrap cellreflist cellref weather projectilemanager
cellpreloader datetimemanager groundcoverstore magiceffects cell ptrregistry
positioncellgrid
)
add_openmw_dir (mwphysics
physicssystem trace collisiontype actor convert object heightfield closestnotmerayresultcallback
contacttestresultcallback stepper movementsolver projectile
actorconvexcallback raycasting mtphysics contacttestwrapper projectileconvexcallback
)
add_openmw_dir (mwclass
classes activator creature npc weapon armor potion apparatus book clothing container door
ingredient creaturelevlist itemlevlist light lockpick misc probe repair static actor bodypart
esm4base esm4npc light4
)
add_openmw_dir (mwmechanics
mechanicsmanagerimp stat creaturestats magiceffects movement actorutil spelllist
drawstate spells activespells npcstats aipackage aisequence aipursue alchemy aiwander aitravel aifollow aiavoiddoor aibreathe
aicast aiescort aiface aiactivate aicombat recharge repair enchanting pathfinding pathgrid security spellcasting spellresistance
disease pickpocket levelledlist combat steering obstacle autocalcspell difficultyscaling aicombataction summoning
character actors objects aistate weaponpriority spellpriority weapontype spellutil
spelleffects
)
add_openmw_dir (mwstate
statemanagerimp charactermanager character quicksavemanager
)
add_openmw_dir (mwbase
environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager
inputmanager windowmanager statemanager luamanager
)
# Main executable
add_library(openmw-lib STATIC
${OPENMW_FILES}
${OPENMW_SOURCES}
)
if(BUILD_OPENMW)
if (ANDROID)
add_library(openmw SHARED
${OPENMW_FILES}
main.cpp
android_main.cpp
)
else()
openmw_add_executable(openmw
${APPLE_BUNDLE_RESOURCES}
${OPENMW_RESOURCES}
main.cpp
)
endif()
target_link_libraries(openmw openmw-lib)
endif()
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
# when we change the backend.
include_directories(
${FFmpeg_INCLUDE_DIRS}
)
target_link_libraries(openmw-lib
# CMake's built-in OSG finder does not use pkgconfig, so we have to
# manually ensure the order is correct for inter-library dependencies.
# This only makes a difference with `-DOPENMW_USE_SYSTEM_OSG=ON -DOSG_STATIC=ON`.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21701
${OSGPARTICLE_LIBRARIES}
${OSGVIEWER_LIBRARIES}
${OSGGA_LIBRARIES}
${OSGSHADOW_LIBRARIES}
${OSGDB_LIBRARIES}
${OSGUTIL_LIBRARIES}
${OSG_LIBRARIES}
Boost::program_options
${OPENAL_LIBRARY}
${FFmpeg_LIBRARIES}
${MyGUI_LIBRARIES}
SDL2::SDL2
${RecastNavigation_LIBRARIES}
"osg-ffmpeg-videoplayer"
"oics"
components
)
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw-lib PRIVATE
<boost/program_options/options_description.hpp>
<sol/sol.hpp>
<osg/StateSet>
<osg/Node>
<osg/Drawable>
<osg/Camera>
<osgViewer/Viewer>
<MyGUI_Widget.h>
<algorithm>
<filesystem>
<fstream>
<functional>
<memory>
<string>
<string_view>
<vector>
)
endif()
add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON)
if (ANDROID)
target_link_libraries(openmw-lib EGL android log z)
endif (ANDROID)
if (USE_SYSTEM_TINYXML)
target_link_libraries(openmw-lib ${TinyXML_LIBRARIES})
endif()
if (NOT UNIX)
target_link_libraries(openmw-lib ${SDL2MAIN_LIBRARY})
endif()
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(openmw-lib ${CMAKE_THREAD_LIBS_INIT})
endif()
if(APPLE AND BUILD_OPENMW)
set(BUNDLE_RESOURCES_DIR "${APP_BUNDLE_DIR}/Contents/Resources")
set(OPENMW_RESOURCES_ROOT ${BUNDLE_RESOURCES_DIR})
add_subdirectory(../../files/ ${CMAKE_CURRENT_BINARY_DIR}/files)
configure_file("${OpenMW_BINARY_DIR}/defaults.bin" ${BUNDLE_RESOURCES_DIR} COPYONLY)
configure_file("${OpenMW_BINARY_DIR}/openmw.cfg" ${BUNDLE_RESOURCES_DIR} COPYONLY)
configure_file("${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" ${BUNDLE_RESOURCES_DIR} COPYONLY)
add_custom_command(TARGET openmw
POST_BUILD
COMMAND cp "${OpenMW_BINARY_DIR}/resources/version" "${BUNDLE_RESOURCES_DIR}/resources")
find_library(COCOA_FRAMEWORK Cocoa)
find_library(IOKIT_FRAMEWORK IOKit)
target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})
if (FFmpeg_FOUND)
target_link_options(openmw PRIVATE "LINKER:SHELL:-framework CoreVideo"
"LINKER:SHELL:-framework CoreMedia"
"LINKER:SHELL:-framework VideoToolbox"
"LINKER:SHELL:-framework AudioToolbox"
"LINKER:SHELL:-framework VideoDecodeAcceleration")
endif()
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-lib PRIVATE --coverage)
target_link_libraries(openmw-lib gcov)
if (NOT ANDROID AND BUILD_OPENMW)
target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov)
endif()
endif()
if (WIN32 AND BUILD_OPENMW)
INSTALL(TARGETS openmw RUNTIME DESTINATION ".")
endif()