1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Take advantage of IrrlichtMt CMake target (#11287)

With the CMake changes to IrrlichtMt, it's now possible to use a target for IrrlichtMt.
Besides greatly improving the ease of setting up IrrlichtMt for users building the client, it removes the need for Minetest's CMake to include transitive dependencies such as image libraries, cleaning it up a tiny bit. The PR works by finding the IrrlichtMt package and linking to the target it provides. If the package isn't found and it isn't building the client, it will still fall back to using just the headers of old Irrlicht or IrrlichtMt.
This commit is contained in:
JosiahWI 2021-07-27 12:11:27 -05:00 committed by GitHub
parent 216728cc5e
commit cf136914cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 140 deletions

View file

@ -293,33 +293,7 @@ else()
if(NOT HAIKU AND NOT APPLE)
find_package(X11 REQUIRED)
endif(NOT HAIKU AND NOT APPLE)
##
# The following dependencies are transitive dependencies from Irrlicht.
# Minetest itself does not use them, but we link them so that statically
# linking Irrlicht works.
if(NOT HAIKU AND NOT APPLE)
# This way Xxf86vm is found on OpenBSD too
find_library(XXF86VM_LIBRARY Xxf86vm)
mark_as_advanced(XXF86VM_LIBRARY)
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
endif(NOT HAIKU AND NOT APPLE)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
if(APPLE)
find_library(CARBON_LIB Carbon REQUIRED)
find_library(COCOA_LIB Cocoa REQUIRED)
find_library(IOKIT_LIB IOKit REQUIRED)
mark_as_advanced(
CARBON_LIB
COCOA_LIB
IOKIT_LIB
)
SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
endif(APPLE)
##
endif(BUILD_CLIENT)
endif()
find_package(ZLIB REQUIRED)
set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS})
@ -511,9 +485,7 @@ endif()
include_directories(
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}
${IRRLICHT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${SOUND_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
@ -548,10 +520,7 @@ if(BUILD_CLIENT)
target_link_libraries(
${PROJECT_NAME}
${ZLIB_LIBRARIES}
${IRRLICHT_LIBRARY}
${JPEG_LIBRARIES}
${BZIP2_LIBRARIES}
${PNG_LIBRARIES}
IrrlichtMt::IrrlichtMt
${X11_LIBRARIES}
${SOUND_LIBRARIES}
${SQLITE3_LIBRARY}
@ -559,7 +528,6 @@ if(BUILD_CLIENT)
${GMP_LIBRARY}
${JSON_LIBRARY}
${PLATFORM_LIBS}
${CLIENT_PLATFORM_LIBS}
)
if(NOT USE_LUAJIT)
set_target_properties(${PROJECT_NAME} PROPERTIES
@ -629,6 +597,11 @@ endif(BUILD_CLIENT)
if(BUILD_SERVER)
add_executable(${PROJECT_NAME}server ${server_SRCS} ${extra_windows_SRCS})
add_dependencies(${PROJECT_NAME}server GenerateVersion)
get_target_property(
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
# Doesn't work without PRIVATE/PUBLIC/INTERFACE mode specified.
target_include_directories(${PROJECT_NAME}server PRIVATE ${IRRLICHT_INCLUDES})
target_link_libraries(
${PROJECT_NAME}server
${ZLIB_LIBRARIES}