diff --git a/CMakeLists.txt b/CMakeLists.txt index b7b244a9a..a9ccb8870 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") add_subdirectory(source/Irrlicht) +option(BUILD_HEADLESS "Build in headless mode" ON) option(BUILD_EXAMPLES "Build example applications" FALSE) if(BUILD_EXAMPLES) add_subdirectory(examples) diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index fe1e29d18..d987d869f 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -44,8 +44,10 @@ //! different library versions without having to change the sources. //! Example: NO_IRR_COMPILE_WITH_X11_ would disable X11 -//! Uncomment this line to compile with the SDL device -//#define _IRR_COMPILE_WITH_SDL_DEVICE_ +#if BUILD_HEADLESS +#define _IRR_COMPILE_WITH_SDL_DEVICE_ +#endif + #ifdef NO_IRR_COMPILE_WITH_SDL_DEVICE_ #undef _IRR_COMPILE_WITH_SDL_DEVICE_ #endif diff --git a/include/irrUString.h b/include/irrUString.h index 49cc67044..bd026e070 100644 --- a/include/irrUString.h +++ b/include/irrUString.h @@ -3678,7 +3678,7 @@ namespace unicode //! Hashing algorithm for hashing a ustring. Used for things like unordered_maps. //! Algorithm taken from std::hash. -class hash : public std::unary_function +class hash { public: size_t operator()(const core::ustring& s) const diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 12574d5a7..7dff77179 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -120,8 +120,11 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) if ( ++SDLDeviceInstances == 1 ) { u32 flags = SDL_INIT_TIMER | SDL_INIT_EVENTS; + #if BUILD_HEADLESS + #else if (CreationParams.DriverType != video::EDT_NULL) flags |= SDL_INIT_VIDEO; + #endif #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) flags |= SDL_INIT_JOYSTICK; #endif diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 57a43048f..c30d5614e 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -99,6 +99,10 @@ if(SDL_ENABLED) find_package(SDL2 CONFIG REQUIRED) message(STATUS "Found SDL2: ${SDL2_LIBRARIES}") endif() +if(BUILD_HEADLESS) + find_package(SDL2 REQUIRED) + add_definitions(-DBUILD_HEADLESS=1) +endif() # Platform-specific libs