RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1k stars 182 forks source link

Support "hints" for finding embree #352

Open mathstuf opened 5 years ago

mathstuf commented 5 years ago

In VTK, we use a pattern akin to the following:

# get prefix of the install tree from this file's location (usually `get_filename_component(DIRECTORY)` a number of times on the current file's location
set("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save" "${CMAKE_PREFIX_PATH}")
list(INSERT CMAKE_PREFIX_PATH 0
  ${${CMAKE_FIND_PACKAGE_NAME}_PREFIX_PATH})

# The above code handles ospray and embree in the same install prefix.
# If embree is elsewhere, include a helper file optionally.
include("${CMAKE_CURRENT_LIST_DIR}/embree-helpers.cmake" OPTIONAL)

find_package(embree) # much more likely to Just Work now

# Restore the prefix.
set(CMAKE_PREFIX_PATH "${${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save}")                                                                                                                      
unset("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save")

The helper file can be controlled by an option like OSPRAY_RELOCATABLE_INSTALL (and installed only if this isn't set). This is to help the install tree not bake in host filesystem paths. The helper file would contain something like:

if (NOT embree_DIR)
  set(embree_DIR "<path ospray had when configured>")
endif ()

and always exist in the build tree.

mathstuf commented 5 years ago

Cc: @demarle