Skip to content

Commit

Permalink
[irrlicht] add feature to support unicode path on windows (#9902)
Browse files Browse the repository at this point in the history
* [irrlicht] add feature to support unicode path on windows

* use vcpkg_check_features

* fix tools feature
  • Loading branch information
DailyShana authored Feb 14, 2020
1 parent b9794a5 commit 1be75a2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
17 changes: 12 additions & 5 deletions ports/irrlicht/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Irrlicht directories
# -------------------------------------------------------------------------------------------------
set(IRR_ROOT_DIR "")
set(IRR_SRC_DIR "source/Irrlicht")
set(IRR_INC_DIR "include")
set(IRR_TOOL_DIR "tools")

# Options
# -------------------------------------------------------------------------------------------------
Expand All @@ -19,6 +19,7 @@ if(DEFINED ENV{DXSDK_DIR})
set(DXSDK "ENV{DXSDK_DIR}")
endif()

set(IRR_UNICODE_PATH 0 CACHE BOOL "Whether to enable unicode path support on windows")
set(IRR_FAST_MATH 0 CACHE BOOL "Whether to enable fast maths (at the expense of precision)")
set(IRR_SHARED_LIB 1 CACHE BOOL "Whether to generate shared libraries instead of static libraries")
set(IRR_DIRECTX_SDK ${DXSDK} CACHE PATH "Path to the DirectX SDK (for DirectX 9, this folder should contain /Include, /Lib)")
Expand All @@ -43,10 +44,10 @@ glob_c_cpp_sources(IRR_SRC_FILES_INTERFACE ${IRR_INC_DIR})
glob_c_cpp_sources(IRR_SRC_FILES_AESGLADMAN ${IRR_SRC_DIR}/aesGladman)
glob_c_cpp_sources(IRR_SRC_FILES_LZMA ${IRR_SRC_DIR}/lzma)

glob_c_cpp_sources(IRR_TOOL_FILES_FILE_TO_HEADER ${IRR_ROOT_DIR}/tools/FileToHeader/)
glob_c_cpp_sources(IRR_TOOL_FILES_GUI_EDITOR ${IRR_ROOT_DIR}/tools/GUIEditor/)
glob_c_cpp_sources(IRR_TOOL_FILES_FONT_TOOL ${IRR_ROOT_DIR}/tools/IrrFontTool/newFontTool/)
glob_c_cpp_sources(IRR_TOOL_FILES_MESH_CONVERTER ${IRR_ROOT_DIR}/tools/MeshConverter/)
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/)

# Group files
# -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -161,6 +162,12 @@ if(WIN32)
# Multi processor compilation
target_compile_options(Irrlicht PRIVATE /MP)

# Unicode
if(${IRR_UNICODE_PATH})
target_compile_definitions(Irrlicht PRIVATE UNICODE _UNICODE)
target_compile_definitions(Irrlicht PUBLIC _IRR_WCHAR_FILESYSTEM)
endif()

# Fast math options
if(${IRR_FAST_MATH})
target_compile_options(Irrlicht PRIVATE /fp:fast)
Expand Down
5 changes: 4 additions & 1 deletion ports/irrlicht/CONTROL
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Source: irrlicht
Version: 1.8.4-4
Version: 1.8.4-5
Homepage: http://irrlicht.sourceforge.net
Description: Irrlicht lightning fast 3d engine
Build-Depends: zlib, libpng, bzip2, libjpeg-turbo

Feature: unicode
Description: Support unicode path on windows

Feature: fast-fpu
Description: Enable fast maths (at the expense of precision)

Expand Down
13 changes: 13 additions & 0 deletions ports/irrlicht/fix-encoding.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/Keycodes.h b/include/Keycodes.h
index e56eca1..57ab312 100644
--- a/include/Keycodes.h
+++ b/include/Keycodes.h
@@ -89,7 +89,7 @@ namespace irr
KEY_KEY_X = 0x58, // X key
KEY_KEY_Y = 0x59, // Y key
KEY_KEY_Z = 0x5A, // Z key
- KEY_LWIN = 0x5B, // Left Windows key (MicrosoftŽ NaturalŽ keyboard)
+ KEY_LWIN = 0x5B, // Left Windows key (MicrosoftÂŽ NaturalÂŽ keyboard)
KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard)
KEY_APPS = 0x5D, // Applications key (Natural keyboard)
KEY_SLEEP = 0x5F, // Computer Sleep key
32 changes: 12 additions & 20 deletions ports/irrlicht/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(vcpkg_common_functions)

vcpkg_download_distfile(ARCHIVE
URLS "https://downloads.sourceforge.net/project/irrlicht/Irrlicht%20SDK/1.8/1.8.4/irrlicht-1.8.4.zip"
FILENAME "irrlicht-1.8.4.zip"
Expand All @@ -10,24 +8,21 @@ vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REF "1.8.4"
# [NO_REMOVE_ONE_LEVEL]
# [WORKING_DIRECTORY <${CURRENT_BUILDTREES_DIR}/src>]
# [PATCHES <a.patch>...]
PATCHES
"fix-encoding.patch"
)

# Copy CMakeLists.txt to the source, because Irrlicht does not have one.
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt DESTINATION ${SOURCE_PATH})

set(FAST_MATH FALSE)
if("fast-fpu" IN_LIST FEATURES)
set(FAST_MATH TRUE)
endif()

set(BUILD_TOOLS FALSE)
if("tools" IN_LIST FEATURES)
set(BUILD_TOOLS TRUE)
endif()
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
unicode IRR_UNICODE_PATH
fast-fpu IRR_FAST_MATH
tools IRR_BUILD_TOOLS
)

set(SHARED_LIB TRUE)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
Expand All @@ -38,18 +33,15 @@ vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
OPTIONS
-DIRR_SHARED_LIB=${SHARED_LIB}
-DIRR_FAST_MATH=${FAST_MATH}
-DIRR_BUILD_TOOLS=${BUILD_TOOLS}
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1
-DIRR_SHARED_LIB=${SHARED_LIB}
${FEATURE_OPTIONS}
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets()

if(BUILD_TOOLS)
if("tools" IN_LIST FEATURES)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/irrlicht/)
endif()

Expand Down

0 comments on commit 1be75a2

Please sign in to comment.