Improve IrrCompileConfig handling in cmake

This commit is contained in:
sfan5 2022-05-21 14:26:52 +02:00
parent 00a7741cd4
commit 0732807cc8

@ -48,8 +48,7 @@ find_package(ZLIB REQUIRED)
find_package(JPEG REQUIRED) find_package(JPEG REQUIRED)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
# To configure the features available in this Irrlicht build please edit # To configure the features available in this Irrlicht build please edit include/IrrCompileConfig.h.
# include/IrrCompileConfig.h and re-run CMake from a clean state
include(CheckSymbolExists) include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include)
unset(OGLES1_ENABLED CACHE) unset(OGLES1_ENABLED CACHE)
@ -58,6 +57,9 @@ unset(OGL_ENABLED CACHE)
unset(XINPUT2_ENABLED CACHE) unset(XINPUT2_ENABLED CACHE)
unset(SDL_ENABLED CACHE) unset(SDL_ENABLED CACHE)
# tell cmake about the dependency
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_REQUIRED_INCLUDES}/IrrCompileConfig.h)
check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED) check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED)
if(OGLES1_ENABLED) if(OGLES1_ENABLED)
# only tested on Android, probably works on Linux (is this needed anywhere else?) # only tested on Android, probably works on Linux (is this needed anywhere else?)
@ -75,11 +77,12 @@ if(OGL_ENABLED)
set(OpenGL_GL_PREFERENCE "LEGACY") set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
endif() endif()
check_symbol_exists(_IRR_LINUX_X11_XINPUT2_ "IrrCompileConfig.h" XINPUT2_ENABLED) if(NOT ANDROID AND NOT APPLE)
if(XINPUT2_ENABLED) check_symbol_exists(_IRR_LINUX_X11_XINPUT2_ "IrrCompileConfig.h" XINPUT2_ENABLED)
if(XINPUT2_ENABLED)
find_library(XINPUT_LIBRARY Xi REQUIRED) find_library(XINPUT_LIBRARY Xi REQUIRED)
endif()
endif() endif()
check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED) check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED)
if(SDL_ENABLED) if(SDL_ENABLED)
find_package(SDL2 CONFIG REQUIRED) find_package(SDL2 CONFIG REQUIRED)