forked from Mirrorlandia_minetest/irrlicht
Move platform detection to CMake
This commit is contained in:
parent
38f18eec56
commit
06db7b7ab7
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@ -48,9 +48,7 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
sed '/#define _IRR_COMPILE_WITH_OGLES2_/ s|^//||g' -i include/IrrCompileConfig.h
|
||||
sed '/#define _IRR_COMPILE_WITH_OPENGL_/ s|^|//|g' -i include/IrrCompileConfig.h
|
||||
cmake . -DBUILD_EXAMPLES=1
|
||||
cmake . -DBUILD_EXAMPLES=1 -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON
|
||||
make -j2
|
||||
|
||||
- name: Test (headless)
|
||||
@ -61,7 +59,7 @@ jobs:
|
||||
- name: Test (Xvfb)
|
||||
run: |
|
||||
cd bin/Linux
|
||||
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest
|
||||
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
|
||||
|
||||
linux-sdl:
|
||||
runs-on: ubuntu-latest
|
||||
@ -77,8 +75,7 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
sed '/#define _IRR_COMPILE_WITH_SDL_DEVICE_/ s|^//||g' -i include/IrrCompileConfig.h
|
||||
cmake . -DBUILD_EXAMPLES=1
|
||||
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON
|
||||
make -j2
|
||||
|
||||
- name: Test (headless)
|
||||
|
@ -10,15 +10,17 @@ static int test_fail = 0;
|
||||
void test_irr_array();
|
||||
void test_irr_string();
|
||||
|
||||
static video::E_DRIVER_TYPE chooseDriver(const char *arg_)
|
||||
static video::E_DRIVER_TYPE chooseDriver(core::stringc arg_)
|
||||
{
|
||||
if (core::stringc(arg_) == "null")
|
||||
if (arg_ == "null")
|
||||
return video::EDT_NULL;
|
||||
|
||||
if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES1))
|
||||
if (arg_ == "ogles1")
|
||||
return video::EDT_OGLES1;
|
||||
if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES2))
|
||||
if (arg_ == "ogles2")
|
||||
return video::EDT_OGLES2;
|
||||
if (arg_ == "opengl")
|
||||
return video::EDT_OPENGL;
|
||||
std::cerr << "Unknown driver type: " << arg_.c_str() << ". Trying OpenGL." << std::endl;
|
||||
return video::EDT_OPENGL;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace irr
|
||||
|
||||
//! A device which uses Simple DirectMedia Layer
|
||||
/** The SDL device works under all platforms supported by SDL but first must be compiled
|
||||
in by defining the _IRR_COMPILE_WITH_SDL_DEVICE_ macro in IrrCompileConfig.h */
|
||||
in by setting the USE_SDL2 CMake option to ON */
|
||||
EIDT_SDL,
|
||||
|
||||
//! This selection allows Irrlicht to choose the best device from the ones available.
|
||||
|
@ -452,10 +452,10 @@ struct SEvent
|
||||
/** Unlike other events, joystick events represent the result of polling
|
||||
* each connected joystick once per run() of the device. Joystick events will
|
||||
* not be generated by default. If joystick support is available for the
|
||||
* active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and
|
||||
* @ref irr::IrrlichtDevice::activateJoysticks() has been called, an event of
|
||||
* this type will be generated once per joystick per @ref IrrlichtDevice::run()
|
||||
* regardless of whether the state of the joystick has actually changed. */
|
||||
* active device, and @ref irr::IrrlichtDevice::activateJoysticks() has been
|
||||
* called, an event of this type will be generated once per joystick per
|
||||
* @ref IrrlichtDevice::run() regardless of whether the state of the joystick
|
||||
* has actually changed. */
|
||||
struct SJoystickEvent
|
||||
{
|
||||
enum
|
||||
|
@ -20,243 +20,10 @@
|
||||
|
||||
#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw
|
||||
|
||||
//! The defines for different operating system are:
|
||||
//! _IRR_WINDOWS_ for all irrlicht supported Windows versions
|
||||
//! _IRR_WINDOWS_API_ for Windows or XBox
|
||||
//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined)
|
||||
//! _IRR_SOLARIS_PLATFORM_ for Solaris
|
||||
//! _IRR_OSX_PLATFORM_ for Apple systems running OSX
|
||||
//! _IRR_IOS_PLATFORM_ for Apple devices running iOS
|
||||
//! _IRR_ANDROID_PLATFORM_ for devices running Android
|
||||
//! _IRR_POSIX_API_ for Posix compatible systems
|
||||
//! Note: PLATFORM defines the OS specific layer, API can group several platforms
|
||||
|
||||
//! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE
|
||||
//! Irrlicht can be compiled with more than one device
|
||||
//! _IRR_COMPILE_WITH_WINDOWS_DEVICE_ for Windows API based device
|
||||
//! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX
|
||||
//! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device
|
||||
//! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework
|
||||
|
||||
//! Passing defines to the compiler which have NO in front of the _IRR definename is an alternative
|
||||
//! way which can be used to disable defines (instead of outcommenting them in this header).
|
||||
//! So defines can be controlled from Makefiles or Projectfiles which allows building
|
||||
//! 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_
|
||||
#ifdef NO_IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#undef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#endif
|
||||
|
||||
//! WIN32 for Windows32
|
||||
//! WIN64 for Windows64
|
||||
// The windows platform and API support SDL and WINDOW device
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define _IRR_WINDOWS_
|
||||
#define _IRR_WINDOWS_API_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#define _IRR_IOS_PLATFORM_
|
||||
#define _IRR_COMPILE_WITH_IOS_DEVICE_
|
||||
#define NO_IRR_COMPILE_WITH_OPENGL_
|
||||
// The application state events and following methods: IrrlichtDevice::isWindowActive, IrrlichtDevice::isWindowFocused,
|
||||
// IrrlichtDevice::isWindowMinimized works out of box only if you'll use built-in CIrrDelegateiOS,
|
||||
// so _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ must be enabled in this case. If you need a custom UIApplicationDelegate
|
||||
// you must disable _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ definition and handle all application events yourself.
|
||||
#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
|
||||
#else
|
||||
#define _IRR_OSX_PLATFORM_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
#endif
|
||||
#define NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#define NO_IRR_COMPILE_WITH_OGLES2_
|
||||
#define NO_IRR_COMPILE_WITH_WEBGL1_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#define _IRR_EMSCRIPTEN_PLATFORM_
|
||||
#define NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#define NO_IRR_COMPILE_WITH_OPENGL_
|
||||
#define NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#define _IRR_COMPILE_WITH_OGLES2_
|
||||
#define _IRR_COMPILE_WITH_WEBGL1_
|
||||
#define _IRR_COMPILE_WITH_EGL_MANAGER_
|
||||
#define _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define NO_IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#define _IRR_LINUX_PLATFORM_ // emscripten basically working like a unix
|
||||
#endif // __EMSCRIPTEN__
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#define _IRR_ANDROID_PLATFORM_
|
||||
#define _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
#define _IRR_COMPILE_ANDROID_ASSET_READER_
|
||||
#define NO_IRR_COMPILE_WITH_OPENGL_
|
||||
#endif
|
||||
|
||||
#if defined(__SVR4) && defined(__sun)
|
||||
#define _IRR_SOLARIS_PLATFORM_
|
||||
#if defined(__sparc)
|
||||
#define __BIG_ENDIAN__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_IOS_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_) && !defined(_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
#ifndef _IRR_SOLARIS_PLATFORM_
|
||||
#define _IRR_LINUX_PLATFORM_
|
||||
#endif
|
||||
#define _IRR_POSIX_API_
|
||||
#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
|
||||
#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
|
||||
#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#endif
|
||||
#ifdef NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#endif
|
||||
|
||||
|
||||
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.
|
||||
#define _IRR_MATERIAL_MAX_TEXTURES_ 4
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL.
|
||||
/** If you do not wish the engine to be compiled with OpenGL, comment this
|
||||
define out. */
|
||||
#define _IRR_COMPILE_WITH_OPENGL_
|
||||
#ifdef NO_IRR_COMPILE_WITH_OPENGL_
|
||||
#undef _IRR_COMPILE_WITH_OPENGL_
|
||||
#endif
|
||||
|
||||
//! Define required options for OpenGL drivers.
|
||||
#if defined(_IRR_COMPILE_WITH_OPENGL_)
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
#define _IRR_OPENGL_USE_EXTPOINTER_
|
||||
#define _IRR_COMPILE_WITH_WGL_MANAGER_
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#define _IRR_OPENGL_USE_EXTPOINTER_
|
||||
#define _IRR_COMPILE_WITH_GLX_MANAGER_
|
||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#define _IRR_COMPILE_WITH_NSOGL_MANAGER_
|
||||
#elif defined(_IRR_SOLARIS_PLATFORM_)
|
||||
#define _IRR_COMPILE_WITH_GLX_MANAGER_
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
#define _IRR_OPENGL_USE_EXTPOINTER_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_OGLES1_ to compile the Irrlicht engine with OpenGL ES 1.1.
|
||||
/** If you do not wish the engine to be compiled with OpenGL ES 1.1, comment this
|
||||
define out.
|
||||
Depending on platform you may have to enable _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ as well when using it.
|
||||
*/
|
||||
#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)
|
||||
#define _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
#ifdef NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#undef _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
//! Define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ to use the OpenGL ES headers from the Debian Khronos-api package
|
||||
//#define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_
|
||||
#endif
|
||||
|
||||
//! Define required options for OpenGL ES 1.1 drivers.
|
||||
#if defined(_IRR_COMPILE_WITH_OGLES1_)
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#define _IRR_OGLES1_USE_EXTPOINTER_
|
||||
#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_
|
||||
#define _IRR_COMPILE_WITH_EGL_MANAGER_
|
||||
#endif
|
||||
#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
|
||||
#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_
|
||||
#define _IRR_COMPILE_WITH_EAGL_MANAGER_
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_OGLES2_ to compile the Irrlicht engine with OpenGL ES 2.0.
|
||||
/** If you do not wish the engine to be compiled with OpenGL ES 2.0, comment this
|
||||
define out. */
|
||||
#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)
|
||||
#define _IRR_COMPILE_WITH_OGLES2_
|
||||
#else
|
||||
//#define _IRR_COMPILE_WITH_OGLES2_
|
||||
#endif
|
||||
#ifdef NO_IRR_COMPILE_WITH_OGLES2_
|
||||
#undef _IRR_COMPILE_WITH_OGLES2_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_WEBGL1_ to compile Irrlicht engine with a WebGL friendly
|
||||
//! subset of the OpenGL ES 2.0 driver.
|
||||
//#define _IRR_COMPILE_WITH_WEBGL1_
|
||||
#ifdef NO_IRR_COMPILE_WITH_WEBGL1_
|
||||
#undef _IRR_COMPILE_WITH_WEBGL1_
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
#define _IRR_COMPILE_WITH_OGLES2_ // it's a subset of OGL ES2, so always needed when using WebGL
|
||||
#endif
|
||||
|
||||
//! Define required options for OpenGL ES 2.0 drivers.
|
||||
#if defined(_IRR_COMPILE_WITH_OGLES2_)
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(__EMSCRIPTEN__)
|
||||
#define _IRR_OGLES2_USE_EXTPOINTER_
|
||||
#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_
|
||||
#define _IRR_COMPILE_WITH_EGL_MANAGER_
|
||||
#endif
|
||||
#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
|
||||
#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_
|
||||
#define _IRR_COMPILE_WITH_EAGL_MANAGER_
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support.
|
||||
/** If you do not wish the engine to be compiled with X11, comment this
|
||||
define out. */
|
||||
// Only used in LinuxDevice.
|
||||
#define _IRR_COMPILE_WITH_X11_
|
||||
#ifdef NO_IRR_COMPILE_WITH_X11_
|
||||
#undef _IRR_COMPILE_WITH_X11_
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)
|
||||
//! XInput2 (library called Xi) is currently only used to support touch-input.
|
||||
#define _IRR_LINUX_X11_XINPUT2_
|
||||
#ifdef NO_IRR_LINUX_X11_XINPUT2_
|
||||
#undef _IRR_LINUX_X11_XINPUT2_
|
||||
#endif
|
||||
|
||||
//! X11 has by default only monochrome cursors, but using the Xcursor library we can also get color cursor support.
|
||||
//! If you have the need for custom color cursors on X11 then enable this and make sure you also link
|
||||
//! to the Xcursor library in your Makefile/Projectfile.
|
||||
//#define _IRR_LINUX_XCURSOR_
|
||||
#ifdef NO_IRR_LINUX_XCURSOR_
|
||||
#undef _IRR_LINUX_XCURSOR_
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_IRR_SOLARIS_PLATFORM_)
|
||||
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
|
||||
|
@ -235,8 +235,8 @@ namespace irr
|
||||
as this would consume joystick info that 3rd party libraries might rely on. Call this method to
|
||||
activate joystick support in Irrlicht and to receive irr::SJoystickEvent events.
|
||||
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.
|
||||
\return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
is defined, false if joysticks are not supported or support is compiled out.
|
||||
\return true if joysticks are supported on this device, false if joysticks are not
|
||||
supported or support is compiled out.
|
||||
*/
|
||||
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;
|
||||
|
||||
@ -310,37 +310,7 @@ namespace irr
|
||||
for a configuration requested when creating the device. */
|
||||
static bool isDriverSupported(video::E_DRIVER_TYPE driver)
|
||||
{
|
||||
switch (driver)
|
||||
{
|
||||
case video::EDT_NULL:
|
||||
return true;
|
||||
case video::EDT_OPENGL:
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case video::EDT_OGLES1:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case video::EDT_OGLES2:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case video::EDT_WEBGL1:
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace irr
|
||||
UsePerformanceTimer(true),
|
||||
SDK_version_do_not_use(IRRLICHT_SDK_VERSION),
|
||||
PrivateData(0),
|
||||
#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) || defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
#ifdef IRR_MOBILE_PATHS
|
||||
OGLES2ShaderPath("media/Shaders/")
|
||||
#else
|
||||
OGLES2ShaderPath("../../media/Shaders/")
|
||||
|
@ -13,7 +13,7 @@ namespace irr
|
||||
|
||||
static io::path getExampleMediaPath()
|
||||
{
|
||||
#if defined (_IRR_IOS_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_) || defined (_IRR_OSX_PLATFORM_) || defined (_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
#ifdef IRR_MOBILE_PATHS
|
||||
return io::path("media/");
|
||||
#else
|
||||
return io::path("../../media/");
|
||||
|
@ -174,7 +174,7 @@ inline core::array<u8> getUnicodeBOM(EUTF_ENCODE mode)
|
||||
COPY_ARRAY(BOM_ENCODE_UTF8, BOM_ENCODE_UTF8_LEN);
|
||||
break;
|
||||
case EUTFE_UTF16:
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
COPY_ARRAY(BOM_ENCODE_UTF16_BE, BOM_ENCODE_UTF16_LEN);
|
||||
#else
|
||||
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
|
||||
@ -187,7 +187,7 @@ inline core::array<u8> getUnicodeBOM(EUTF_ENCODE mode)
|
||||
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
|
||||
break;
|
||||
case EUTFE_UTF32:
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
COPY_ARRAY(BOM_ENCODE_UTF32_BE, BOM_ENCODE_UTF32_LEN);
|
||||
#else
|
||||
COPY_ARRAY(BOM_ENCODE_UTF32_LE, BOM_ENCODE_UTF32_LEN);
|
||||
|
@ -1,4 +1,5 @@
|
||||
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
|
||||
option(USE_SDL2 "Use the SDL2 backend" FALSE)
|
||||
|
||||
# Compiler flags
|
||||
|
||||
@ -56,46 +57,195 @@ if(NOT REVISION_SANITY_CHECK)
|
||||
message(FATAL_ERROR "IrrlichtMt revision number mismatches between CMake and headers.")
|
||||
endif()
|
||||
|
||||
# Platform-specific configuration
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
set(SOLARIS TRUE)
|
||||
endif()
|
||||
if(APPLE AND NOT IOS)
|
||||
set(OSX TRUE)
|
||||
endif()
|
||||
|
||||
# Device
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_)
|
||||
set(DEVICE "WINDOWS")
|
||||
elseif(IOS)
|
||||
add_definitions(-D_IRR_IOS_PLATFORM_ -D_IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_)
|
||||
if(USE_SDL2)
|
||||
message(WARNING "SDL2 backend is not supported on iOS")
|
||||
set(USE_SDL2 FALSE)
|
||||
endif()
|
||||
set(DEVICE "IOS")
|
||||
elseif(OSX)
|
||||
add_definitions(-D_IRR_OSX_PLATFORM_)
|
||||
set(DEVICE "OSX")
|
||||
elseif(ANDROID)
|
||||
add_definitions(-D_IRR_ANDROID_PLATFORM_ -D_IRR_COMPILE_ANDROID_ASSET_READER_)
|
||||
if(USE_SDL2)
|
||||
message(WARNING "SDL2 backend is not supported on Android")
|
||||
set(USE_SDL2 FALSE)
|
||||
endif()
|
||||
set(DEVICE "Android")
|
||||
elseif(EMSCRIPTEN)
|
||||
add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
set(LINUX_PLATFORM TRUE)
|
||||
set(DEVICE "SDL")
|
||||
elseif(SOLARIS)
|
||||
add_definitions(-D_IRR_SOLARIS_PLATFORM_ -D_IRR_POSIX_API_)
|
||||
set(DEVICE "X11")
|
||||
else()
|
||||
add_definitions(-D_IRR_POSIX_API_)
|
||||
set(LINUX_PLATFORM TRUE)
|
||||
set(DEVICE "X11")
|
||||
endif()
|
||||
|
||||
if(USE_SDL2)
|
||||
set(DEVICE "SDL")
|
||||
endif()
|
||||
|
||||
option(USE_X11 "Use X11" TRUE)
|
||||
if(USE_X11)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_X11_)
|
||||
endif()
|
||||
|
||||
if(LINUX_PLATFORM)
|
||||
add_definitions(-D_IRR_LINUX_PLATFORM_)
|
||||
endif()
|
||||
|
||||
if(LINUX_PLATFORM AND USE_X11)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_X11_)
|
||||
|
||||
option(USE_XINPUT2 "Use XInput2" TRUE)
|
||||
if(USE_XINPUT2)
|
||||
add_definitions(-D_IRR_LINUX_X11_XINPUT2_)
|
||||
endif()
|
||||
|
||||
option(USE_XCURSOR "Use XCursor" FALSE)
|
||||
if(USE_XCURSOR)
|
||||
add_definitions(-D_IRR_LINUX_XCURSOR_)
|
||||
endif()
|
||||
else()
|
||||
set(USE_XINPUT2 FALSE)
|
||||
set(USE_XCURSOR FALSE)
|
||||
endif()
|
||||
|
||||
add_definitions("-D_IRR_COMPILE_WITH_${DEVICE}_DEVICE_")
|
||||
|
||||
# Joystick
|
||||
|
||||
if(NOT (BSD OR SOLARIS OR EMSCRIPTEN))
|
||||
add_definitions(-D_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
|
||||
endif()
|
||||
|
||||
# OpenGL
|
||||
|
||||
if(IOS OR ANDROID OR EMSCRIPTEN)
|
||||
set(ENABLE_OPENGL FALSE)
|
||||
else()
|
||||
option(ENABLE_OPENGL "Enable OpenGL" TRUE)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN OR OSX)
|
||||
set(ENABLE_GLES1 FALSE)
|
||||
else()
|
||||
if(ANDROID OR IOS)
|
||||
set(DEFAULT_GLES1 TRUE)
|
||||
endif()
|
||||
option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1})
|
||||
endif()
|
||||
|
||||
if(OSX)
|
||||
set(ENABLE_GLES2 FALSE)
|
||||
set(ENABLE_WEBGL1 FALSE)
|
||||
else()
|
||||
if(ANDROID OR IOS OR EMSCRIPTEN)
|
||||
set(DEFAULT_GLES2 TRUE)
|
||||
endif()
|
||||
if(EMSCRIPTEN)
|
||||
set(DEFAULT_WEBGL1 TRUE)
|
||||
endif()
|
||||
option(ENABLE_GLES2 "Enable OpenGL ES 2+" ${DEFAULT_GLES2})
|
||||
option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1})
|
||||
if(ENABLE_WEBGL1)
|
||||
set(ENABLE_GLES2 TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
|
||||
if(DEVICE STREQUAL "WINDOWS")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
elseif(DEVICE STREQUAL "X11")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
elseif(DEVICE STREQUAL "OSX")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_)
|
||||
elseif(DEVICE STREQUAL "SDL")
|
||||
add_definitions(-D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLES1)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
|
||||
if(DEVICE MATCHES "^WINDOWS|X11|ANDROID$")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
elseif(DEVICE STREQUAL "IOS")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLES2)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
|
||||
if(DEVICE MATCHES "^WINDOWS|X11|ANDROID$" OR EMSCRIPTEN)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_)
|
||||
elseif(DEVICE STREQUAL "IOS")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_WEBGL1)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WEBGL1_)
|
||||
endif()
|
||||
|
||||
# Misc
|
||||
|
||||
include(TestBigEndian)
|
||||
TEST_BIG_ENDIAN(BIG_ENDIAN)
|
||||
if(BIG_ENDIAN)
|
||||
add_definitions(-D__BIG_ENDIAN__)
|
||||
endif()
|
||||
|
||||
# Configuration report
|
||||
|
||||
message(STATUS "Device: ${DEVICE}")
|
||||
message(STATUS "OpenGL: ${ENABLE_OPENGL}")
|
||||
message(STATUS "OpenGL ES: ${ENABLE_GLES1}")
|
||||
message(STATUS "OpenGL ES 2: ${ENABLE_GLES2}")
|
||||
message(STATUS "WebGL: ${ENABLE_WEBGL1}")
|
||||
|
||||
# Required libs
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
|
||||
# To configure the features available in this Irrlicht build please edit include/IrrCompileConfig.h.
|
||||
include(CheckSymbolExists)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include)
|
||||
unset(OGLES1_ENABLED CACHE)
|
||||
unset(OGLES2_ENABLED CACHE)
|
||||
unset(OGL_ENABLED CACHE)
|
||||
unset(XINPUT2_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)
|
||||
if(OGLES1_ENABLED)
|
||||
if(ENABLE_GLES1)
|
||||
# only tested on Android, probably works on Linux (is this needed anywhere else?)
|
||||
find_library(OPENGLES_LIBRARY NAMES GLESv1_CM REQUIRED)
|
||||
find_library(EGL_LIBRARY NAMES EGL REQUIRED)
|
||||
|
||||
message(STATUS "Found OpenGLES: ${OPENGLES_LIBRARY}")
|
||||
endif()
|
||||
check_symbol_exists(_IRR_COMPILE_WITH_OGLES2_ "IrrCompileConfig.h" OGLES2_ENABLED)
|
||||
if(OGLES2_ENABLED)
|
||||
if(ENABLE_GLES2)
|
||||
find_package(OpenGLES2 REQUIRED)
|
||||
endif()
|
||||
check_symbol_exists(_IRR_COMPILE_WITH_OPENGL_ "IrrCompileConfig.h" OGL_ENABLED)
|
||||
if(OGL_ENABLED)
|
||||
if(ENABLE_OPENGL)
|
||||
set(OpenGL_GL_PREFERENCE "LEGACY")
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
if(UNIX AND NOT ANDROID AND NOT APPLE)
|
||||
check_symbol_exists(_IRR_LINUX_X11_XINPUT2_ "IrrCompileConfig.h" XINPUT2_ENABLED)
|
||||
endif()
|
||||
check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED)
|
||||
if(SDL_ENABLED)
|
||||
if(USE_SDL2)
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
|
||||
endif()
|
||||
@ -113,7 +263,7 @@ elseif(APPLE)
|
||||
else()
|
||||
# Unix probably
|
||||
find_package(X11 REQUIRED)
|
||||
if(XINPUT2_ENABLED AND NOT X11_Xi_FOUND)
|
||||
if(${USE_XINPUT2} AND NOT X11_Xi_FOUND)
|
||||
message(FATAL_ERROR "XInput not found")
|
||||
endif()
|
||||
endif()
|
||||
@ -307,6 +457,12 @@ target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_)
|
||||
endif()
|
||||
if(WIN32)
|
||||
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_)
|
||||
endif()
|
||||
if(APPLE OR ANDROID OR EMSCRIPTEN)
|
||||
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
|
||||
endif()
|
||||
|
||||
set_target_properties(IrrlichtMt PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
|
Loading…
Reference in New Issue
Block a user