summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorNeroBurner <pyro4hell@gmail.com>2021-06-29 09:57:19 +0200
committerGitHub <noreply@github.com>2021-06-29 10:57:19 +0300
commitfa4dee0e62dcf2bbfb68b17cf97e438eab58be93 (patch)
tree951a36caf1816c5b22ef79ccae679afdf51af016 /CMakeLists.txt
parent63fc728a84a5ba97240233ad1c5d94f1ade2deb1 (diff)
downloadminetest-fa4dee0e62dcf2bbfb68b17cf97e438eab58be93.tar.gz
minetest-fa4dee0e62dcf2bbfb68b17cf97e438eab58be93.tar.bz2
minetest-fa4dee0e62dcf2bbfb68b17cf97e438eab58be93.zip
Use user provided lib/irrlichtmt if available (#11276)
Use user provided lib/irrlichtmt if available Make it possible for a user to provide the IrrlichtMt dependency as subdirectory at `lib/irrlichtmt`. The subdirectory is added with the `EXCLUDE_FROM_ALL` flag to prevent `libirrlichtmt.a` or other header files to be installed. This enables the user to do the following to satisfy the IrrlichtMt dependency: git clone --depth 1 https://github.com/minetest/irrlicht.git lib/irrlichtmt cmake . -DRUN_IN_PLACE=TRUE
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt26
1 files changed, 21 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f90847ea..42b343540 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,11 +58,27 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# This is done here so that relative search paths are more reasonable
-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.")
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/irrlichtmt")
+ message(STATUS "Using user-provided IrrlichtMt at subdirectory 'lib/irrlichtmt'")
+ # tell IrrlichtMt to create a static library
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared library" FORCE)
+ add_subdirectory(lib/irrlichtmt EXCLUDE_FROM_ALL)
+ unset(BUILD_SHARED_LIBS CACHE)
+
+ 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()
include(CheckSymbolExists)