Skip to content

Commit 54b05d2

Browse files
committed
fix(win): Embed manifest in OIIO .exes to enable long path handling
Signed-off-by: Nathan Rusch <nrusch@github>
1 parent 43b8aa9 commit 54b05d2

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/cmake/fancy_add_executable.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ macro (fancy_add_executable)
4444
check_is_enabled (${_target_NAME} _target_NAME_enabled)
4545
if (_target_NAME_enabled)
4646
add_executable (${_target_NAME} ${_target_SRC})
47+
if (WIN32)
48+
# Disable default manifest generation to avoid conflicts.
49+
target_link_options(${_target_NAME} PRIVATE "/MANIFEST:NO")
50+
# Include Windows resource file, which will in turn embed our exe manifest.
51+
target_sources(${_target_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/src/windows/oiio_exe.rc")
52+
endif ()
4753
target_include_directories (${_target_NAME} PRIVATE ${_target_INCLUDE_DIRS})
4854
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
4955
target_compile_definitions (${_target_NAME} PRIVATE

src/windows/oiio_exe.manifest

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
4+
<security>
5+
<requestedPrivileges>
6+
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
7+
</requestedPrivileges>
8+
</security>
9+
</trustInfo>
10+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
11+
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
12+
<ws2:longPathAware>true</ws2:longPathAware>
13+
</windowsSettings>
14+
</application>
15+
</assembly>

src/windows/oiio_exe.rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Resource script for OIIO EXEs.
2+
3+
// The value is invariant, so should be safe to hardcode, but we could replace
4+
// 24 with `RT_MANIFEST` by adding `#include "winres.h"` first.
5+
// Reference: https://learn.microsoft.com/en-us/windows/win32/menurc/user-defined-resource
6+
1 24 "oiio_exe.manifest"

0 commit comments

Comments
 (0)