From 5fa8c717ea9fbf5949e6222526314feca2944c20 Mon Sep 17 00:00:00 2001 From: Artem Shubovych Date: Wed, 7 Jul 2021 06:51:11 +1000 Subject: [irrlicht] Add OSX support (#18725) * Fix Irrlicht compilation on OSX * Update port description * Update portfile instructions * Update version * Fix patch files * Add missing cmake dependencies * Remove obsolete comment * Update version * Remove OBJCXX language from project definition to prevent Windows builds from failing * Update versions * Code review tweaks * Update version * Update versions/i-/irrlicht.json Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Fix qt5-3d build failure on OSX * Update qt5-3d version * Update port-version for qt5-3d * Update version for qt5-3d * [qt5-3d] Revert modification to previous version entry Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Co-authored-by: Robert Schumacher --- ports/irrlicht/CMakeLists.txt | 57 +++++++++++++++++++++++--------- ports/irrlicht/CONTROL | 9 ++--- ports/irrlicht/fix-osx-compilation.patch | 28 ++++++++++++++++ ports/irrlicht/portfile.cmake | 16 +++++---- ports/qt5-3d/CONTROL | 1 + ports/qt5-3d/portfile.cmake | 2 ++ scripts/ci.baseline.txt | 1 - versions/baseline.json | 6 ++-- versions/i-/irrlicht.json | 5 +++ versions/q-/qt5-3d.json | 5 +++ 10 files changed, 100 insertions(+), 30 deletions(-) create mode 100644 ports/irrlicht/fix-osx-compilation.patch diff --git a/ports/irrlicht/CMakeLists.txt b/ports/irrlicht/CMakeLists.txt index d7e0c8f50..cc6edc785 100644 --- a/ports/irrlicht/CMakeLists.txt +++ b/ports/irrlicht/CMakeLists.txt @@ -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") @@ -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}) @@ -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) @@ -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 $ @@ -177,7 +203,6 @@ if(WIN32) target_compile_options(Irrlicht PRIVATE /arch:SSE2) endif() endif() - elseif(UNIX) # Standard mode target_compile_options(Irrlicht @@ -185,7 +210,7 @@ elseif(UNIX) 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) @@ -194,10 +219,12 @@ elseif(UNIX) target_compile_options(Irrlicht PRIVATE $<$:-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 @@ -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 ) diff --git a/ports/irrlicht/CONTROL b/ports/irrlicht/CONTROL index e8ff45bdd..5161a33b2 100644 --- a/ports/irrlicht/CONTROL +++ b/ports/irrlicht/CONTROL @@ -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 diff --git a/ports/irrlicht/fix-osx-compilation.patch b/ports/irrlicht/fix-osx-compilation.patch new file mode 100644 index 000000000..6f623db26 --- /dev/null +++ b/ports/irrlicht/fix-osx-compilation.patch @@ -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)[[[AppDelegate alloc] initWithDevice:this] autorelease]]; ++ [[NSApplication sharedApplication] activateIgnoringOtherApps]; ++ [NSApp setDelegate:(id)[[[AppDelegate alloc] initWithDevice:this] autorelease]]; + [NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]]; + [NSApp finishLaunching]; + } diff --git a/ports/irrlicht/portfile.cmake b/ports/irrlicht/portfile.cmake index 754119f3e..9641f8fdd 100644 --- a/ports/irrlicht/portfile.cmake +++ b/ports/irrlicht/portfile.cmake @@ -1,4 +1,4 @@ -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 @@ -6,7 +6,10 @@ vcpkg_from_sourceforge( 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) @@ -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/) diff --git a/ports/qt5-3d/CONTROL b/ports/qt5-3d/CONTROL index 7868a6595..1ec0c15a6 100644 --- a/ports/qt5-3d/CONTROL +++ b/ports/qt5-3d/CONTROL @@ -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 diff --git a/ports/qt5-3d/portfile.cmake b/ports/qt5-3d/portfile.cmake index 912bad83d..62a01e4de 100644 --- a/ports/qt5-3d/portfile.cmake +++ b/ports/qt5-3d/portfile.cmake @@ -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() diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 668d0e0f2..f8f39297a 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -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 diff --git a/versions/baseline.json b/versions/baseline.json index cda1afe2e..2bbc7331d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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", @@ -5090,7 +5090,7 @@ }, "qt5-3d": { "baseline": "5.15.2", - "port-version": 0 + "port-version": 1 }, "qt5-activeqt": { "baseline": "5.15.2", diff --git a/versions/i-/irrlicht.json b/versions/i-/irrlicht.json index a5fb44f20..6d884cfe3 100644 --- a/versions/i-/irrlicht.json +++ b/versions/i-/irrlicht.json @@ -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", diff --git a/versions/q-/qt5-3d.json b/versions/q-/qt5-3d.json index d29595cbe..ca2dd24e7 100644 --- a/versions/q-/qt5-3d.json +++ b/versions/q-/qt5-3d.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "6c3c15324a4764d3501798299c8ad8087905b136", + "version-string": "5.15.2", + "port-version": 1 + }, { "git-tree": "c9a8b7a2360c554409f283143edf9202bebe6a3b", "version-string": "5.15.2", -- cgit v1.2.3