]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Add variable to use existing IrrlichtMt build (#11656)
authorJosiahWI <41302989+JosiahWI@users.noreply.github.com>
Sun, 31 Oct 2021 22:33:11 +0000 (17:33 -0500)
committerGitHub <noreply@github.com>
Sun, 31 Oct 2021 22:33:11 +0000 (22:33 +0000)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
CMakeLists.txt
README.md

index e542d3509c44ac3f94d0dd3c0c81704e95b3cef5..b41738c065d784036c25a0ca2f83c9cdcf8fed1a 100644 (file)
@@ -52,7 +52,6 @@ set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
 set(BUILD_SERVER FALSE CACHE BOOL "Build server")
 set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
 
-
 set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
 
 if(NOT CMAKE_BUILD_TYPE)
@@ -64,8 +63,21 @@ endif()
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 
 
+set(IRRLICHTMT_BUILD_DIR "" CACHE PATH "Path to IrrlichtMt build directory.")
+if(NOT "${IRRLICHTMT_BUILD_DIR}" STREQUAL "")
+       find_package(IrrlichtMt QUIET
+               PATHS "${IRRLICHTMT_BUILD_DIR}"
+               NO_DEFAULT_PATH
+)
+
+       if(NOT TARGET IrrlichtMt::IrrlichtMt)
+               # find_package() searches certain subdirectories. ${PATH}/cmake is not
+               # the only one, but it is the one where IrrlichtMt is supposed to export
+               # IrrlichtMtConfig.cmake
+               message(FATAL_ERROR "Could not find IrrlichtMtConfig.cmake in ${IRRLICHTMT_BUILD_DIR}/cmake.")
+       endif()
 # This is done here so that relative search paths are more reasonable
-if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt")
+elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt")
        message(STATUS "Using user-provided IrrlichtMt at subdirectory 'lib/irrlichtmt'")
        if(BUILD_CLIENT)
                # tell IrrlichtMt to create a static library
@@ -101,11 +113,13 @@ else()
                # 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}")
-       else()
-               message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}")
        endif()
 endif()
 
+if(TARGET IrrlichtMt::IrrlichtMt)
+       message(STATUS "Found IrrlichtMt ${IrrlichtMt_VERSION}")
+endif()
+
 
 # Installation
 
index 9322912cf8ceaf6d59ba31b54c76a4a15d698903..65dbd7e934a704ad77a7ef594b2506f3588751e3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -224,10 +224,13 @@ Run it:
   - Debug build is slower, but gives much more useful output in a debugger.
 - If you build a bare server you don't need to have the Irrlicht or IrrlichtMt library installed.
   - In that case use `-DIRRLICHT_INCLUDE_DIR=/some/where/irrlicht/include`.
-- IrrlichtMt can also be installed somewhere that is not a standard install path.
-  - In that case use `-DCMAKE_PREFIX_PATH=/path/to/install_prefix`
-  - The path must be set so that `$(CMAKE_PREFIX_PATH)/lib/cmake/IrrlichtMt` exists
-    or that `$(CMAKE_PREFIX_PATH)` is the path of an IrrlichtMt build folder.
+
+- Minetest will use the IrrlichtMt package that is found first, given by the following order:
+  1. Specified `IRRLICHTMT_BUILD_DIR` CMake variable
+  2. `${PROJECT_SOURCE_DIR}/lib/irrlichtmt` (if existent)
+  3. Installation of IrrlichtMt in the system-specific library paths
+  4. For server builds with disabled `BUILD_CLIENT` variable, the headers from `IRRLICHT_INCLUDE_DIR` will be used.
+  - NOTE: Changing the IrrlichtMt build directory (includes system installs) requires regenerating the CMake cache (`rm CMakeCache.txt`)
 
 ### CMake options