Fix build with system static OpenSceneGraph

* Add dependency to libraries required by OSG but missing when linking with OSG
  system library.
* Use find_package for already defined dependencies.
pull/3121/head
elsid 3 years ago
parent e4648cec48
commit b9825afb8a
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -13,6 +13,11 @@ if(POLICY CMP0083)
cmake_policy(SET CMP0083 NEW)
endif()
# to link with freetype library
if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif()
option(OPENMW_GL4ES_MANUAL_INIT "Manually initialize gl4es. This is more reliable on platforms without a windowing system. Requires gl4es to be configured with -DNOEGL=ON -DNO_LOADER=ON -DNO_INIT_CONSTRUCTOR=ON." OFF)
if(OPENMW_GL4ES_MANUAL_INIT)
add_definitions(-DOPENMW_GL4ES_MANUAL_INIT)

@ -288,6 +288,15 @@ if (GIT_CHECKOUT)
add_dependencies (components git-version)
endif (GIT_CHECKOUT)
if (OSG_STATIC AND CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(X11 REQUIRED COMPONENTS Xinerama Xrandr)
target_link_libraries(components ${CMAKE_DL_LIBS} X11::X11 X11::Xinerama X11::Xrandr)
find_package(Fontconfig MODULE)
if(Fontconfig_FOUND)
target_link_libraries(components Fontconfig::Fontconfig)
endif()
endif()
if (WIN32)
target_link_libraries(components shlwapi)
endif()
@ -329,7 +338,10 @@ if(OSG_STATIC)
if(OPENMW_USE_SYSTEM_OSG)
# OSG plugin pkgconfig files are missing these dependencies.
# https://github.com/openscenegraph/OpenSceneGraph/issues/1052
target_link_libraries(components freetype jpeg png)
find_package(Freetype REQUIRED)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
target_link_libraries(components Freetype::Freetype JPEG::JPEG PNG::PNG)
endif()
endif(OSG_STATIC)

Loading…
Cancel
Save