build: simplify light build (embree handling)
This commit is contained in:
parent
527c63f55f
commit
bd3452bfdc
|
|
@ -60,7 +60,7 @@ target_link_libraries (light PRIVATE ${CMAKE_THREAD_LIBS_INIT})
|
|||
if (embree_FOUND)
|
||||
target_link_libraries (light PRIVATE embree)
|
||||
add_definitions(-DHAVE_EMBREE)
|
||||
|
||||
|
||||
find_file(EMBREE_LICENSE LICENSE.txt
|
||||
"${embree_DIR}/doc"
|
||||
"${embree_DIR}/../embree3/embree3" # vcpkg puts it here
|
||||
|
|
@ -72,48 +72,18 @@ if (embree_FOUND)
|
|||
message(STATUS "Found embree license: ${EMBREE_LICENSE}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
file(GLOB EMBREE_DLLS "${embree_DIR}/bin/*.dll")
|
||||
foreach(EMBREE_DLL ${EMBREE_DLLS})
|
||||
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DLL} $<TARGET_FILE_DIR:light>)
|
||||
endforeach(EMBREE_DLL)
|
||||
|
||||
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_LICENSE} $<TARGET_FILE_DIR:light>/LICENSE-embree.txt)
|
||||
add_custom_command(TARGET light POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:embree>" "$<TARGET_FILE_DIR:light>"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:light>"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_LICENSE}" "$<TARGET_FILE_DIR:light>/LICENSE-embree.txt")
|
||||
|
||||
install(FILES ${EMBREE_DLLS} DESTINATION bin)
|
||||
endif()
|
||||
if(UNIX)
|
||||
if (APPLE)
|
||||
set(SHARED_LIB_EXT dylib)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(SHARED_LIB_EXT "so.*")
|
||||
else ()
|
||||
message(FATAL_ERROR "only Linux and macOS currently supported")
|
||||
endif()
|
||||
|
||||
|
||||
file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/lib/*.${SHARED_LIB_EXT}")
|
||||
|
||||
# Gather all .dylib's that are not symlinks
|
||||
foreach(EMBREE_DYLIB ${EMBREE_DYLIBS_WITH_SYMLINKS})
|
||||
if(NOT IS_SYMLINK ${EMBREE_DYLIB})
|
||||
list(APPEND EMBREE_DYLIBS ${EMBREE_DYLIB})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(EMBREE_DYLIB ${EMBREE_DYLIBS})
|
||||
message(STATUS "Copying dylib: ${EMBREE_DYLIB}")
|
||||
add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DYLIB} $<TARGET_FILE_DIR:light>)
|
||||
endforeach()
|
||||
|
||||
# so the executable will search for dylib's in the same directory as the executable
|
||||
if(APPLE)
|
||||
add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
|
||||
endif()
|
||||
|
||||
install(FILES ${EMBREE_DYLIBS} DESTINATION bin)
|
||||
# so the executable will search for dylib's in the same directory as the executable
|
||||
if(APPLE)
|
||||
add_custom_command(TARGET light POST_BUILD
|
||||
COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
|
||||
endif()
|
||||
|
||||
install(FILES "$<TARGET_FILE:embree>" "$<TARGET_FILE:TBB::tbb>" DESTINATION bin)
|
||||
install(FILES ${EMBREE_LICENSE} DESTINATION bin RENAME LICENSE-embree.txt)
|
||||
endif(embree_FOUND)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue