Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[irrlicht] Add OSX support #18725

Merged
merged 18 commits into from
Jul 6, 2021
57 changes: 42 additions & 15 deletions ports/irrlicht/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
# Irrlicht 3D engine
#
cmake_minimum_required(VERSION 3.8)
project(Irrlicht)
cmake_minimum_required(VERSION 3.16)
project(Irrlicht LANGUAGES C CXX)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Irrlicht directories
# -------------------------------------------------------------------------------------------------
set(IRR_SRC_DIR "source/Irrlicht")
Expand Down Expand Up @@ -48,7 +48,15 @@ glob_c_cpp_sources(IRR_TOOL_FILES_FILE_TO_HEADER ${IRR_TOOL_DIR}/FileToHeader
glob_c_cpp_sources(IRR_TOOL_FILES_GUI_EDITOR ${IRR_TOOL_DIR}/GUIEditor/)
glob_c_cpp_sources(IRR_TOOL_FILES_FONT_TOOL ${IRR_TOOL_DIR}/IrrFontTool/newFontTool/)
glob_c_cpp_sources(IRR_TOOL_FILES_MESH_CONVERTER ${IRR_TOOL_DIR}/MeshConverter/)


if(APPLE)
file(GLOB IRR_SRC_FILES_OSX
"${IRR_SRC_DIR}/MacOSX/*.mm"
"${IRR_SRC_DIR}/MacOSX/*.h")

set(IRR_SRC_FILES ${IRR_SRC_FILES} ${IRR_SRC_FILES_OSX})
endif()

# Group files
# -------------------------------------------------------------------------------------------------
source_group(Irrlicht\\engine FILES ${IRR_SRC_FILES})
Expand Down Expand Up @@ -79,11 +87,29 @@ else()
add_library(Irrlicht STATIC ${IRR_ALL_SRC_FILES})
endif()

target_link_libraries(Irrlicht PRIVATE
${PNG_LIBRARY}
${JPEG_LIBRARY}
if(APPLE)
target_include_directories(Irrlicht PRIVATE ${IRR_SRC_DIR}/MacOSX)

target_compile_definitions(Irrlicht PRIVATE SYSTEM=MacOSX)

target_link_libraries(Irrlicht ${OSX_LIBRARIES})

target_compile_options(Irrlicht PRIVATE "-ObjC++")

set(ADDITIONAL_LIRARIES
"-framework OpenGL"
"-framework IOKit"
"-framework Carbon"
"-framework AppKit"
"-framework Cocoa")
endif()

target_link_libraries(Irrlicht PRIVATE
${PNG_LIBRARY}
${JPEG_LIBRARY}
${ZLIB_LIBRARY}
${BZIP2_LIBRARY}
${ADDITIONAL_LIRARIES}
)

if(IRR_BUILD_TOOLS)
Expand Down Expand Up @@ -112,7 +138,7 @@ target_include_directories(Irrlicht
)

# I dont realy understand why this is necesary or what it is doing,
# but it is necesarry to build and export a package.
# but it is necesarry to build and export a package.
# See: https://cmake.org/cmake/help/v3.8/command/target_include_directories.html
target_include_directories(Irrlicht PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -177,15 +203,14 @@ if(WIN32)
target_compile_options(Irrlicht PRIVATE /arch:SSE2)
endif()
endif()

elseif(UNIX)
# Standard mode
target_compile_options(Irrlicht
PRIVATE -Wall
PRIVATE -pipe
PRIVATE -fno-exceptions
PRIVATE -fno-strict-aliasing)

# Disable RTTI on C++ files only (no sense for C files)
set_source_files_properties(${IRR_SRC_FILES} ${IRR_SRC_FILES_AESGLADMAN}
PROPERTIES COMPILE_FLAGS -fno-rtti)
Expand All @@ -194,10 +219,12 @@ elseif(UNIX)
target_compile_options(Irrlicht PRIVATE $<$<CONFIG:Debug>:-D_DEBUG>)

# X11 and OpenGL
target_link_libraries(Irrlicht
PRIVATE X11
PRIVATE GL
PRIVATE Xxf86vm)
if(NOT APPLE)
target_link_libraries(Irrlicht
PRIVATE X11
PRIVATE GL
PRIVATE Xxf86vm)
endif()
endif()

# Installation
Expand All @@ -214,7 +241,7 @@ install(FILES ${IRR_SRC_FILES_INTERFACE} DESTINATION "include/irrlicht" CONFIGUR

if(IRR_BUILD_TOOLS)
install(
TARGETS FileToHeader GUIEditor FontTool MeshConverter
TARGETS FileToHeader GUIEditor FontTool MeshConverter
RUNTIME DESTINATION tools/irrlicht/
CONFIGURATIONS Release
)
Expand Down
9 changes: 5 additions & 4 deletions ports/irrlicht/CONTROL
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Source: irrlicht
Version: 1.8.4-10
Version: 1.8.4
Port-Version: 11
Homepage: http://irrlicht.sourceforge.net
Description: Irrlicht lightning fast 3d engine
Build-Depends: zlib, libpng, bzip2, libjpeg-turbo
Supports: !(arm|uwp|osx)
Description: The Irrlicht Engine is an open source realtime 3D engine written in C++. It is cross-platform, using D3D, OpenGL and its own software renderers.
Build-Depends: zlib, libpng, bzip2, libjpeg-turbo, vcpkg-cmake, vcpkg-cmake-config
Supports: !(arm|uwp)

Feature: unicode
Description: Support unicode path on windows
Expand Down
28 changes: 28 additions & 0 deletions ports/irrlicht/fix-osx-compilation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/source/Irrlicht/CImageLoaderJPG.cpp b/source/Irrlicht/CImageLoaderJPG.cpp
index 66144326c..4ea224c24 100644
--- a/source/Irrlicht/CImageLoaderJPG.cpp
+++ b/source/Irrlicht/CImageLoaderJPG.cpp
@@ -68,7 +68,7 @@ void CImageLoaderJPG::init_source (j_decompress_ptr cinfo)
boolean CImageLoaderJPG::fill_input_buffer (j_decompress_ptr cinfo)
{
// DO NOTHING
- return 1;
+ return TRUE;
}


diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
index 53029eb45..e75b707e1 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
@@ -495,8 +495,8 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
if(!CreationParams.WindowId) //load menus if standalone application
{
[[NSAutoreleasePool alloc] init];
- [NSApplication sharedApplication];
- [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
+ [[NSApplication sharedApplication] activateIgnoringOtherApps];
+ [NSApp setDelegate:(id<NSApplicationDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
[NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
[NSApp finishLaunching];
}
16 changes: 9 additions & 7 deletions ports/irrlicht/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "osx" "uwp")
vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "uwp")

vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO irrlicht/Irrlicht%20SDK
REF 1.8/1.8.4
FILENAME "irrlicht-1.8.4.zip"
SHA512 de69ddd2c6bc80a1b27b9a620e3697b1baa552f24c7d624076d471f3aecd9b15f71dce3b640811e6ece20f49b57688d428e3503936a7926b3e3b0cc696af98d1
PATCHES fix-encoding.patch fix-sysctl.patch
PATCHES
fix-encoding.patch
fix-sysctl.patch
fix-osx-compilation.patch
)

configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt ${SOURCE_PATH}/CMakeLists.txt COPYONLY)
Expand All @@ -21,17 +24,16 @@ vcpkg_check_features(

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SHARED_LIB)

vcpkg_configure_cmake(
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
OPTIONS
OPTIONS
-DIRR_SHARED_LIB=${SHARED_LIB}
${FEATURE_OPTIONS}
)

vcpkg_install_cmake()
vcpkg_cmake_install()

vcpkg_fixup_cmake_targets()
vcpkg_cmake_config_fixup()

if("tools" IN_LIST FEATURES)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/irrlicht/)
Expand Down
1 change: 1 addition & 0 deletions ports/qt5-3d/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Source: qt5-3d
Version: 5.15.2
Port-Version: 1
Description: Qt5 3d Module - Functionality for near-realtime simulation systems with support for 2D and 3D rendering
Build-Depends: qt5-base[core], qt5-declarative, qt5-imageformats, qt5-gamepad, assimp
2 changes: 2 additions & 0 deletions ports/qt5-3d/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ if(BZ2_DBG)
endif()
if(VCPKG_TARGET_IS_WINDOWS)
set(SYSTEM_LIBS "Advapi32.lib user32.lib gdi32.lib")
elseif(VCPKG_TARGET_IS_OSX)
set(SYSTEM_LIBS "-framework OpenGL -framework Cocoa -framework Carbon -framework IOKit -framework AppKit")
else()
set(SYSTEM_LIBS "-lGL -lXxf86vm -lX11")
endif()
Expand Down
1 change: 0 additions & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ intelrdfpmathlib:x64-linux=fail
intelrdfpmathlib:x64-uwp=fail
irrlicht:arm64-windows=fail
irrlicht:arm-uwp=fail
irrlicht:x64-osx=fail
irrlicht:x64-uwp=fail
isal:arm64-windows=fail
isal:arm-uwp=fail
Expand Down
10 changes: 5 additions & 5 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2701,8 +2701,8 @@
"port-version": 2
},
"irrlicht": {
"baseline": "1.8.4-10",
"port-version": 0
"baseline": "1.8.4",
"port-version": 11
},
"irrxml": {
"baseline": "0",
Expand Down Expand Up @@ -3539,8 +3539,8 @@
"libsigcpp-3": {
"baseline": "3.0.3",
"port-version": 1
},
"libsmb2": {
},
"libsmb2": {
"baseline": "2021-04-29",
"port-version": 0
},
Expand Down Expand Up @@ -5086,7 +5086,7 @@
},
"qt5-3d": {
"baseline": "5.15.2",
"port-version": 0
"port-version": 1
},
"qt5-activeqt": {
"baseline": "5.15.2",
Expand Down
5 changes: 5 additions & 0 deletions versions/i-/irrlicht.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "18ae08d6099b5457ccedbdb7209c79321a9e9027",
"version-string": "1.8.4",
"port-version": 11
},
{
"git-tree": "e2b2dd836e693401dab067c5064665e926a46b07",
"version-string": "1.8.4-10",
Expand Down
5 changes: 5 additions & 0 deletions versions/q-/qt5-3d.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "6c3c15324a4764d3501798299c8ad8087905b136",
"version-string": "5.15.2",
"port-version": 1
},
{
"git-tree": "c9a8b7a2360c554409f283143edf9202bebe6a3b",
"version-string": "5.15.2",
Expand Down