2021-07-16 23:11:59 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
|
|
|
|
|
|
|
|
# Compiler flags
|
|
|
|
|
|
|
|
add_definitions(-DIRRLICHT_EXPORTS)
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
add_definitions(-D_IRR_STATIC_LIB_)
|
|
|
|
endif()
|
2021-03-06 21:23:00 +01:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
add_definitions(-D_DEBUG)
|
|
|
|
endif()
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
2021-08-07 21:56:00 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2021-03-06 21:23:00 +01:00
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
|
|
|
|
|
|
|
add_compile_options(-Wall -pipe -fno-exceptions -fno-rtti)
|
|
|
|
elseif(MSVC)
|
2021-03-26 16:48:28 +01:00
|
|
|
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " msvcrt.lib") # ???? fuck off
|
2021-03-06 21:23:00 +01:00
|
|
|
|
2021-03-26 16:48:28 +01:00
|
|
|
add_compile_options(/GR- /Zl)
|
2021-03-06 21:23:00 +01:00
|
|
|
endif()
|
|
|
|
|
2021-03-06 22:14:46 +01:00
|
|
|
# Required libs
|
|
|
|
|
2021-03-06 21:23:00 +01:00
|
|
|
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 and re-run CMake from a clean state
|
|
|
|
include(CheckSymbolExists)
|
2021-06-30 21:13:59 +02:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include)
|
2021-03-25 14:14:44 +01:00
|
|
|
unset(OGLES1_ENABLED CACHE)
|
|
|
|
unset(OGLES2_ENABLED CACHE)
|
|
|
|
unset(OGL_ENABLED CACHE)
|
2021-03-06 21:23:00 +01:00
|
|
|
|
2021-03-07 01:08:58 +01:00
|
|
|
check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED)
|
|
|
|
if(OGLES1_ENABLED)
|
|
|
|
# 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()
|
2021-03-06 21:23:00 +01:00
|
|
|
check_symbol_exists(_IRR_COMPILE_WITH_OGLES2_ "IrrCompileConfig.h" OGLES2_ENABLED)
|
|
|
|
if(OGLES2_ENABLED)
|
|
|
|
find_package(OpenGLES2 REQUIRED)
|
|
|
|
endif()
|
|
|
|
check_symbol_exists(_IRR_COMPILE_WITH_OPENGL_ "IrrCompileConfig.h" OGL_ENABLED)
|
|
|
|
if(OGL_ENABLED)
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Platform-specific libs
|
|
|
|
|
|
|
|
if(ANDROID)
|
2021-04-09 21:28:31 +02:00
|
|
|
enable_language(C)
|
2021-03-07 01:08:58 +01:00
|
|
|
add_library(native_app_glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
2021-03-06 21:23:00 +01:00
|
|
|
elseif(APPLE)
|
2021-03-06 22:14:46 +01:00
|
|
|
find_library(COCOA_LIB Cocoa REQUIRED)
|
|
|
|
find_library(IOKIT_LIB IOKit REQUIRED)
|
2021-03-08 13:36:44 +01:00
|
|
|
|
|
|
|
add_definitions(-DGL_SILENCE_DEPRECATION)
|
2021-03-06 21:23:00 +01:00
|
|
|
else()
|
|
|
|
# Unix probably
|
|
|
|
find_package(X11 REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2021-06-27 23:04:56 +02:00
|
|
|
set(link_includes
|
2021-05-24 20:32:26 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/include"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
|
|
|
|
"${ZLIB_INCLUDE_DIR}"
|
|
|
|
"${JPEG_INCLUDE_DIR}"
|
|
|
|
"${PNG_INCLUDE_DIR}"
|
|
|
|
|
|
|
|
${OPENGL_INCLUDE_DIR}
|
|
|
|
${OPENGLES2_INCLUDE_DIR}
|
|
|
|
${EGL_INCLUDE_DIR}
|
|
|
|
|
|
|
|
"$<$<PLATFORM_ID:Android>:${ANDROID_NDK}/sources/android/native_app_glue>"
|
|
|
|
${X11_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(link_libs
|
|
|
|
"${ZLIB_LIBRARY}"
|
|
|
|
"${JPEG_LIBRARY}"
|
|
|
|
"${PNG_LIBRARY}"
|
|
|
|
|
|
|
|
${OPENGL_LIBRARIES}
|
|
|
|
${OPENGLES_LIBRARY}
|
|
|
|
${OPENGLES2_LIBRARIES}
|
|
|
|
${EGL_LIBRARY}
|
|
|
|
|
|
|
|
"$<$<PLATFORM_ID:Android>:native_app_glue -landroid -llog>"
|
|
|
|
${COCOA_LIB}
|
|
|
|
${IOKIT_LIB}
|
|
|
|
"$<$<PLATFORM_ID:Windows>:gdi32>"
|
|
|
|
"$<$<PLATFORM_ID:Windows>:winmm>"
|
|
|
|
${X11_X11_LIB}
|
|
|
|
${X11_Xxf86vm_LIB}
|
|
|
|
)
|
|
|
|
|
2021-03-06 21:23:00 +01:00
|
|
|
# Source files
|
|
|
|
|
|
|
|
set(IRRMESHLOADER
|
|
|
|
CB3DMeshFileLoader.cpp
|
|
|
|
COBJMeshFileLoader.cpp
|
|
|
|
CXMeshFileLoader.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(IRRMESHOBJ OBJECT
|
|
|
|
CSkinnedMesh.cpp
|
|
|
|
CBoneSceneNode.cpp
|
|
|
|
CMeshSceneNode.cpp
|
|
|
|
CAnimatedMeshSceneNode.cpp
|
|
|
|
${IRRMESHLOADER}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(IRROBJ OBJECT
|
|
|
|
CBillboardSceneNode.cpp
|
|
|
|
CCameraSceneNode.cpp
|
|
|
|
CDummyTransformationSceneNode.cpp
|
|
|
|
CEmptySceneNode.cpp
|
|
|
|
CMeshManipulator.cpp
|
|
|
|
CSceneManager.cpp
|
|
|
|
CMeshCache.cpp
|
|
|
|
CDefaultSceneNodeFactory.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(IRRDRVROBJ
|
|
|
|
CNullDriver.cpp
|
|
|
|
COpenGLCacheHandler.cpp
|
|
|
|
COpenGLDriver.cpp
|
|
|
|
COpenGLNormalMapRenderer.cpp
|
|
|
|
COpenGLParallaxMapRenderer.cpp
|
|
|
|
COpenGLShaderMaterialRenderer.cpp
|
|
|
|
COpenGLSLMaterialRenderer.cpp
|
|
|
|
COpenGLExtensionHandler.cpp
|
|
|
|
COGLESDriver.cpp
|
|
|
|
COGLESExtensionHandler.cpp
|
|
|
|
COGLES2Driver.cpp
|
|
|
|
COGLES2ExtensionHandler.cpp
|
|
|
|
COGLES2FixedPipelineRenderer.cpp
|
|
|
|
COGLES2MaterialRenderer.cpp
|
|
|
|
COGLES2NormalMapRenderer.cpp
|
|
|
|
COGLES2ParallaxMapRenderer.cpp
|
|
|
|
COGLES2Renderer2D.cpp
|
|
|
|
CWebGL1Driver.cpp
|
|
|
|
CGLXManager.cpp
|
|
|
|
CWGLManager.cpp
|
|
|
|
CEGLManager.cpp
|
2021-08-07 21:56:00 +02:00
|
|
|
mt_opengl_loader.cpp
|
2021-03-06 21:23:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
set(IRRIMAGEOBJ
|
|
|
|
CColorConverter.cpp
|
|
|
|
CImage.cpp
|
|
|
|
CImageLoaderBMP.cpp
|
|
|
|
CImageLoaderJPG.cpp
|
|
|
|
CImageLoaderPNG.cpp
|
|
|
|
CImageWriterJPG.cpp
|
|
|
|
CImageWriterPNG.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(IRRVIDEOOBJ OBJECT
|
|
|
|
CVideoModeList.cpp
|
|
|
|
CFPSCounter.cpp
|
|
|
|
${IRRDRVROBJ}
|
|
|
|
${IRRIMAGEOBJ}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(IRRIOOBJ OBJECT
|
|
|
|
CFileList.cpp
|
|
|
|
CFileSystem.cpp
|
|
|
|
CLimitReadFile.cpp
|
|
|
|
CMemoryFile.cpp
|
|
|
|
CReadFile.cpp
|
|
|
|
CWriteFile.cpp
|
|
|
|
CZipReader.cpp
|
|
|
|
CMountPointReader.cpp
|
|
|
|
CAttributes.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(IRROTHEROBJ OBJECT
|
|
|
|
CIrrDeviceSDL.cpp
|
|
|
|
CIrrDeviceLinux.cpp
|
|
|
|
CIrrDeviceConsole.cpp
|
|
|
|
CIrrDeviceStub.cpp
|
|
|
|
CIrrDeviceWin32.cpp
|
|
|
|
CIrrDeviceFB.cpp
|
|
|
|
CLogger.cpp
|
|
|
|
COSOperator.cpp
|
|
|
|
Irrlicht.cpp
|
|
|
|
os.cpp
|
|
|
|
leakHunter.cpp
|
|
|
|
CProfiler.cpp
|
|
|
|
utf8.cpp
|
|
|
|
)
|
|
|
|
|
2021-03-07 01:08:58 +01:00
|
|
|
if(ANDROID)
|
|
|
|
target_sources(IRROTHEROBJ PRIVATE
|
|
|
|
Android/CIrrDeviceAndroid.cpp
|
|
|
|
Android/CAndroidAssetReader.cpp
|
|
|
|
Android/CAndroidAssetFileArchive.cpp
|
|
|
|
Android/CKeyEventWrapper.cpp
|
|
|
|
)
|
|
|
|
elseif(APPLE)
|
2021-03-06 22:14:46 +01:00
|
|
|
# Build all IRROTHEROBJ sources as objc++, including the .cpp's
|
|
|
|
set_target_properties(IRROTHEROBJ PROPERTIES COMPILE_OPTIONS "-xobjective-c++")
|
|
|
|
target_sources(IRROTHEROBJ PRIVATE
|
|
|
|
CIrrDeviceOSX.mm
|
|
|
|
CNSOGLManager.mm
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-03-06 21:23:00 +01:00
|
|
|
add_library(IRRGUIOBJ OBJECT
|
|
|
|
CGUIButton.cpp
|
|
|
|
CGUICheckBox.cpp
|
|
|
|
CGUIComboBox.cpp
|
|
|
|
CGUIContextMenu.cpp
|
|
|
|
CGUIEditBox.cpp
|
|
|
|
CGUIEnvironment.cpp
|
|
|
|
CGUIFileOpenDialog.cpp
|
|
|
|
CGUIFont.cpp
|
|
|
|
CGUIImage.cpp
|
|
|
|
CGUIInOutFader.cpp
|
|
|
|
CGUIListBox.cpp
|
|
|
|
CGUIMenu.cpp
|
|
|
|
CGUIMeshViewer.cpp
|
|
|
|
CGUIMessageBox.cpp
|
|
|
|
CGUIModalScreen.cpp
|
|
|
|
CGUIScrollBar.cpp
|
|
|
|
CGUISpinBox.cpp
|
|
|
|
CGUISkin.cpp
|
|
|
|
CGUIStaticText.cpp
|
|
|
|
CGUITabControl.cpp
|
|
|
|
CGUITable.cpp
|
|
|
|
CGUIToolBar.cpp
|
|
|
|
CGUIWindow.cpp
|
|
|
|
CGUIColorSelectDialog.cpp
|
|
|
|
CDefaultGUIElementFactory.cpp
|
|
|
|
CGUISpriteBank.cpp
|
|
|
|
CGUIImageList.cpp
|
|
|
|
CGUITreeView.cpp
|
|
|
|
CGUIProfiler.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# Library
|
|
|
|
|
2021-06-27 23:04:56 +02:00
|
|
|
add_library(IrrlichtMt)
|
|
|
|
foreach(object_lib
|
2021-07-23 16:23:44 +02:00
|
|
|
IRRMESHOBJ IRROBJ IRRVIDEOOBJ
|
2021-06-27 23:04:56 +02:00
|
|
|
IRRIOOBJ IRROTHEROBJ IRRGUIOBJ)
|
|
|
|
# Set include directories for object library compilation
|
|
|
|
target_include_directories(${object_lib} PRIVATE ${link_includes})
|
|
|
|
# Add objects from object library to main library
|
|
|
|
target_sources(IrrlichtMt PRIVATE $<TARGET_OBJECTS:${object_lib}>)
|
|
|
|
endforeach()
|
2021-03-06 21:23:00 +01:00
|
|
|
|
2021-05-24 20:32:26 +02:00
|
|
|
# Alias target provides add_submodule compatibility
|
|
|
|
add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt)
|
|
|
|
|
|
|
|
target_include_directories(IrrlichtMt
|
|
|
|
PUBLIC
|
|
|
|
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
|
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt>"
|
|
|
|
PRIVATE
|
2021-06-27 23:04:56 +02:00
|
|
|
${link_includes}
|
2021-05-24 20:32:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
|
|
|
|
|
2021-07-16 23:11:59 +02:00
|
|
|
# Propagate static library flag to lib users, only needed for Windows
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_)
|
|
|
|
endif()
|
|
|
|
|
2021-03-25 14:14:44 +01:00
|
|
|
set_target_properties(IrrlichtMt PROPERTIES
|
2021-04-13 21:08:16 +02:00
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
2021-03-06 21:23:00 +01:00
|
|
|
)
|
2021-03-06 22:14:46 +01:00
|
|
|
|
2021-03-25 14:14:44 +01:00
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(IrrlichtMt PROPERTIES PREFIX "") # for DLL name
|
|
|
|
endif()
|
2021-04-17 17:30:45 +02:00
|
|
|
|
2021-04-24 11:03:09 +02:00
|
|
|
# Installation of library
|
2021-04-17 17:30:45 +02:00
|
|
|
if(ANDROID)
|
2021-04-24 11:03:09 +02:00
|
|
|
set(INSTALL_TARGETS IrrlichtMt native_app_glue)
|
2021-04-17 17:30:45 +02:00
|
|
|
else()
|
2021-04-24 11:03:09 +02:00
|
|
|
set(INSTALL_TARGETS IrrlichtMt)
|
2021-04-17 17:30:45 +02:00
|
|
|
endif()
|
2021-04-24 11:03:09 +02:00
|
|
|
|
|
|
|
install(TARGETS ${INSTALL_TARGETS}
|
|
|
|
EXPORT IrrlichtMt-export
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
)
|