Skip to content

Commit

Permalink
oidn
Browse files Browse the repository at this point in the history
  • Loading branch information
howetuft committed Dec 27, 2024
1 parent 2ae4236 commit 91d400a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
65 changes: 35 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,22 @@ set_property(TARGET oidn-denoise PROPERTY IMPORTED_LOCATION "${LUX_OIDN_DENOISE_


# Installation

# Pyluxcore
INSTALL(TARGETS pyluxcore DESTINATION pyluxcore)


# oidnDenoise (much more work...)
if(WIN32)
# Windows lacks rpath system, so we have to put oidnDenoise in the same
# folder as the dlls...
set(OIDN_DESTINATION "pyluxcore.libs")
else()
# Macos
# Reminder: don't put it in pyluxcore/.dylibs, it would prevent other
# deps' relocation
# For Macos, reminder: don't put it in pyluxcore/.dylibs, it would prevent
# other deps' relocation
set(OIDN_DESTINATION "pyluxcore.oidn")
endif(WIN32)

INSTALL(
IMPORTED_RUNTIME_ARTIFACTS oidn-denoise
DESTINATION ${OIDN_DESTINATION}
PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE

)

if(LINUX)
set_property(
TARGET oidn-denoise
Expand All @@ -170,39 +165,49 @@ if(LINUX)
endif(LINUX)

if(APPLE)
set_property(
TARGET oidn-denoise
PROPERTY BUILD_RPATH ""
)
set_property(
TARGET oidn-denoise
PROPERTY INSTALL_RPATH "\\\${ORIGIN}/../pyluxcore/.pylibs"
set_target_properties(
oidn-denoise PROPERTIES
INSTALL_RPATH "\\\${ORIGIN}/../pyluxcore/.pylibs"
BUILD_RPATH ""
)
endif(APPLE)

INSTALL(
IMPORTED_RUNTIME_ARTIFACTS oidn-denoise
DESTINATION ${OIDN_DESTINATION}
PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)


if(WIN32)
# For Win32, we need to add device_cpu
# device_cpu should first have a pyd extension. This will be reverted after repairing
add_library(oidn-device-cpu SHARED IMPORTED)
set_property(
TARGET oidn-device-cpu
PROPERTY IMPORTED_LOCATION
"${LUX_OIDN_DENOISE_BINS}/OpenImageDenoise_device_cpu.dll"
set_target_properties(
oidn-device-cpu PROPERTIES
IMPORTED_LOCATION "${LUX_OIDN_DENOISE_BINS}/OpenImageDenoise_device_cpu.dll"
OUTPUT_NAME "OpenImageDenoise_device_cpu.pyd"
)
INSTALL(
IMPORTED_RUNTIME_ARTIFACTS oidn-device-cpu
DESTINATION pyluxcore.libs
DESTINATION "pyluxcore.libs"
PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()

if(WIN32)
# Delvewheel doesn't handle executables, however we need to delocate oidnDenoise.
# Therefore we have to let Delvewheel believe oidnDenoise is a lib...
message(STATUS "oidnDenoise SUFFIX pyd")
# Therefore we had to let Delvewheel believe oidnDenoise is a lib, and now
# we have to make it an executable again...
message(STATUS "oidnDenoise suffix back to pyd")
INSTALL(CODE "file(RENAME \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/oidnDenoise.exe\" \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/oidnDenoise.pyd\")")
INSTALL(CODE "file(RENAME \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.dll\" \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.pyd\")")

# TODO
# device_cpu should have a pyd extension
#INSTALL(CODE "file(RENAME \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.dll\" \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.pyd\")")
# This will be reverted after repairing
endif(WIN32)
2 changes: 0 additions & 2 deletions deps/conan/oidn/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ def generate(self):
tc.variables["OIDN_APPS"] = self.options.with_apps
if self.settings.os == "Linux":
tc.cache_variables["CMAKE_SKIP_BUILD_RPATH"] = True
# tc.cache_variables["CMAKE_BUILD_RPATH_USE_ORIGIN"] = True
tc.cache_variables["CMAKE_BUILD_WITH_INSTALL_RPATH"] = True
tc.cache_variables["CMAKE_INSTALL_RPATH"] = "\\\\\${ORIGIN}/."
if self.settings.os == "Macos":
tc.cache_variables["CMAKE_SKIP_RPATH"] = True
Expand Down
1 change: 0 additions & 1 deletion src/pyluxcoretest/pyluxcoretest.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ def ExternalOidn():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
cwd=os.path.dirname(denoiser_path),
env={"LD_DEBUG": "libs"},
)
with denoiser_process.stdout as d_out:
Expand Down

0 comments on commit 91d400a

Please sign in to comment.