summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosiahWI <41302989+JosiahWI@users.noreply.github.com>2021-07-27 12:11:27 -0500
committerGitHub <noreply@github.com>2021-07-27 19:11:27 +0200
commitcf136914cf421ee52f6806eda2fa97740d0ee552 (patch)
tree1068c357c835cad165204d29771df5d1793c89a5 /src
parent216728cc5e83ff6c4f13a52821ff3c24b1e315e9 (diff)
downloadminetest-cf136914cf421ee52f6806eda2fa97740d0ee552.tar.gz
minetest-cf136914cf421ee52f6806eda2fa97740d0ee552.tar.bz2
minetest-cf136914cf421ee52f6806eda2fa97740d0ee552.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ac460883a..7a5e48b49 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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}