diff options
author | JosiahWI <41302989+JosiahWI@users.noreply.github.com> | 2021-07-27 12:11:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 19:11:27 +0200 |
commit | cf136914cf421ee52f6806eda2fa97740d0ee552 (patch) | |
tree | 1068c357c835cad165204d29771df5d1793c89a5 /CMakeLists.txt | |
parent | 216728cc5e83ff6c4f13a52821ff3c24b1e315e9 (diff) | |
download | minetest-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 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 42b343540..fe508ffdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,34 +68,25 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt") if(NOT TARGET IrrlichtMt) message(FATAL_ERROR "IrrlichtMt project is missing a CMake target?!") endif() - - # set include dir the way it would normally be - set(IRRLICHT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt/include") - set(IRRLICHT_LIBRARY IrrlichtMt) else() - 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.") - endif() -endif() + 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") + if(BUILD_CLIENT) + message(FATAL_ERROR "IrrlichtMt is required to build the client, but it was not found.\n${explanation_msg}") + endif() -include(CheckSymbolExists) -set(CMAKE_REQUIRED_INCLUDES ${IRRLICHT_INCLUDE_DIR}) -unset(HAS_FORKED_IRRLICHT CACHE) -check_symbol_exists(IRRLICHT_VERSION_MT "IrrCompileConfig.h" HAS_FORKED_IRRLICHT) -if(NOT HAS_FORKED_IRRLICHT) - string(CONCAT EXPLANATION_MSG - "Irrlicht found, but it is not IrrlichtMt (Minetest's Irrlicht fork). " - "The Minetest team has forked Irrlicht to make their own customizations. " - "It can be found here: https://github.com/minetest/irrlicht") - if(BUILD_CLIENT) - message(FATAL_ERROR "${EXPLANATION_MSG}\n" - "Building the client with upstream Irrlicht is no longer possible.") + 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) + target_include_directories(IrrlichtMt::IrrlichtMt INTERFACE "${IRRLICHT_INCLUDE_DIR}") else() - message(WARNING "${EXPLANATION_MSG}\n" - "The server can still be built with upstream Irrlicht but this is DISCOURAGED.") + message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}") endif() endif() |