Skip to content

Commit 4fd806b

Browse files
AlifianKmo271
authored andcommitted
Attach manifest to enable UTF-8 on Windows (libjxl#3886)
(cherry picked from commit 7b70ef1)
1 parent 432da75 commit 4fd806b

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Aditya Patadia <adityapatadia@users.noreply.github.com>
3535
Ahmad Amsyar Asyadiq Bin Syaiful Bahri <27284123+Ahmad-Amsyar@users.noreply.github.com>
3636
Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
3737
Alexander Sago <cagelight@gmail.com>
38+
Alifian Caesar Khalid <alifiancaesar@gmail.com>
3839
Alistair Barrow
3940
Andrius Lukas Narbutas <andrius4669@gmail.com>
4041
Aous Naman <aous@unsw.edu.au>

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ else ()
330330
if (NOT JPEGXL_ENABLE_SIZELESS_VECTORS)
331331
set(HWY_DISABLED_TARGETS "${HWY_DISABLED_TARGETS}|HWY_SVE|HWY_SVE2|HWY_SVE_256|HWY_SVE2_128|HWY_RVV")
332332
endif()
333-
add_definitions(-DHWY_DISABLED_TARGETS=\(${HWY_DISABLED_TARGETS}\))
333+
add_compile_options($<$<NOT:$<COMPILE_LANGUAGE:RC>>:-DHWY_DISABLED_TARGETS=\(${HWY_DISABLED_TARGETS}\)>)
334334
endif()
335335

336336
# Machine flags.

tools/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,18 @@ foreach(BINARY IN LISTS TOOL_BINARIES)
336336
endif()
337337
set_target_properties(${BINARY} PROPERTIES LINK_FLAGS "${JXL_WASM_TOOLS_LINK_FLAGS}")
338338
endif()
339+
340+
# Attach manifest that tells Windows to use UTF-8 for eg. fopen
341+
if(WIN32)
342+
# Accommodate cl, clang-cl and clang with GNU-like command
343+
if(NOT MINGW)
344+
target_sources(${BINARY} PRIVATE utf8.manifest)
345+
# Since CMake in MINGW doesn't support linking
346+
# .manifest file, do it with .rc file
347+
elseif(MINGW)
348+
target_sources(${BINARY} PRIVATE utf8.rc)
349+
endif()
350+
endif()
339351
endforeach()
340352

341353
install(TARGETS ${TOOL_BINARIES} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

tools/utf8.manifest

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<application>
4+
<windowsSettings>
5+
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
6+
</windowsSettings>
7+
</application>
8+
</assembly>

tools/utf8.rc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <winuser.h>
2+
3+
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "utf8.manifest"

0 commit comments

Comments
 (0)