From 15a136a742f818b4b68ba285b0e48932d26bf26c Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 12 May 2022 00:25:18 -0600 Subject: [PATCH] light/CMakeLists.txt: fix vcpkg builds improve tbb12.dll hack, which is only desired for the embree binary releases --- light/CMakeLists.txt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index d025f139..691ee455 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -64,6 +64,15 @@ if (embree_FOUND) message(STATUS "Found embree license: ${EMBREE_LICENSE}") endif() + # HACK: Windows embree .dll's from https://github.com/embree/embree/releases ship with a tbb12.dll + # and we need to copy it from the embree/bin directory to our light.exe/testlight.exe dir in order for them to run + find_file(EMBREE_TBB_DLL tbb12.dll + "${EMBREE_ROOT_DIR}/bin" + NO_DEFAULT_PATH) + if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND) + message(STATUS "Found embree EMBREE_TBB_DLL: ${EMBREE_TBB_DLL}") + endif() + add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") @@ -72,6 +81,10 @@ if (embree_FOUND) add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_LICENSE}" "$/LICENSE-embree.txt") endif() + if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND) + add_custom_command(TARGET light POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$") + endif() # so the executable will search for dylib's in the same directory as the executable if(APPLE) @@ -123,11 +136,9 @@ if (embree_FOUND) COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") - # HACK: copy embree's tbb12.dll - # FIXME: this is only desired with the .zip release of embree, not e.g. vcpkg - if (WIN32) + if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND) add_custom_command(TARGET testlight POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "$/tbb12.dll" "$") + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_TBB_DLL}" "$") endif() add_definitions(-DHAVE_EMBREE)