- find_package(Irrlicht)
- if(BUILD_CLIENT AND NOT IRRLICHT_FOUND)
- message(FATAL_ERROR "IrrlichtMt is required to build the client, but it was not found.")
- elseif(NOT IRRLICHT_INCLUDE_DIR)
- message(FATAL_ERROR "Irrlicht or IrrlichtMt headers are required to build the server, but none found.")
+ find_package(IrrlichtMt QUIET)
+ if(NOT TARGET IrrlichtMt::IrrlichtMt)
+ string(CONCAT explanation_msg
+ "The Minetest team has forked Irrlicht to make their own customizations. "
+ "It can be found here: https://github.com/minetest/irrlicht\n"
+ "For example use: git clone --depth=1 https://github.com/minetest/irrlicht lib/irrlichtmt\n")
+ if(BUILD_CLIENT)
+ message(FATAL_ERROR "IrrlichtMt is required to build the client, but it was not found.\n${explanation_msg}")
+ endif()
+
+ include(MinetestFindIrrlichtHeaders)
+ if(NOT IRRLICHT_INCLUDE_DIR)
+ message(FATAL_ERROR "Irrlicht or IrrlichtMt headers are required to build the server, but none found.\n${explanation_msg}")
+ endif()
+ message(STATUS "Found Irrlicht headers: ${IRRLICHT_INCLUDE_DIR}")
+ add_library(IrrlichtMt::IrrlichtMt INTERFACE IMPORTED)
+ # Note that we can't use target_include_directories() since that doesn't work for IMPORTED targets before CMake 3.11
+ set_target_properties(IrrlichtMt::IrrlichtMt PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${IRRLICHT_INCLUDE_DIR}")