Skip to content

Commit

Permalink
Clean up ospray cmake code. (#56)
Browse files Browse the repository at this point in the history
Move find logic from root CMakeLists.txt into FindOSPRay.cmake
Remove top-level use of ospray include_directories and link_directories (put them in CMakeLists.txt where needed).
Remove duplicate use of add_definitions for VISIT_OSPRAY. It's needed many places, so it is set in the find module.
Removed unnecessary VISIT_OSRPAY logic from avtplotter CMakeLists.txt
  • Loading branch information
biagas committed Feb 7, 2019
1 parent d70e572 commit cd96a19
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 109 deletions.
132 changes: 132 additions & 0 deletions src/CMake/FindOSPRay.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#*****************************************************************************
#
# Copyright (c) 2000 - 2019, Lawrence Livermore National Security, LLC
# Produced at the Lawrence Livermore National Laboratory
# LLNL-CODE-442911
# All rights reserved.
#
# This file is part of VisIt. For details, see https://visit.llnl.gov/. The
# full copyright notice is contained in the file COPYRIGHT located at the root
# of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
# Modifications:
#
#*****************************************************************************

IF(VISIT_OSPRAY)

# -- this is a hack for TBB_ROOT
IF(NOT DEFINED TBB_ROOT)
SET(TBB_ROOT ${VISIT_TBB_ROOT})
ENDIF()
SET(embree_DIR ${EMBREE_DIR})
MARK_AS_ADVANCED(ospray_DIR)
MARK_AS_ADVANCED(embree_DIR)

# setup ospray
# we have to search for the osprayConfig.cmake file in the ospray install
# folder. Because ospray sometimes install its library in <...>/lib64
# folder instead of the <...>/lib folder, we have to check both
# possibilities
FIND_PACKAGE(ospray REQUIRED
PATHS
${OSPRAY_DIR}/lib/cmake/ospray-${OSPRAY_VERSION}
${OSPRAY_DIR}/lib64/cmake/ospray-${OSPRAY_VERSION}
NO_DEFAULT_PATH)
ADD_DEFINITIONS(-DVISIT_OSPRAY)
# append additional module libraries
list(APPEND OSPRAY_LIBRARIES
${LIBRARY_PATH_PREFIX}ospray_module_ispc${LIBRARY_SUFFIX}
${LIBRARY_PATH_PREFIX}ospray_module_visit${LIBRARY_SUFFIX}
${LIBRARY_PATH_PREFIX}ospray_module_visit_common${LIBRARY_SUFFIX})

# install ospray libs follow visit's standard
#
# -- OSPRAY_LIBRARIES contains also libtbb and libembree, so we dont
# have to handle embree and tbb seperately. As for ISPC, since ISPC
# is only a compiler and will only be needed when we are compiling
# ospray source, we dont have to install ISPC at all here for VisIt.
#
# on linux ospray have libraries in a form of:
# libospray[xxx].so
# libospray[xxx].so.0
# libospray[xxx].so.[version]
#
# on mac ospray have libraries in a form of:
# libospray[xxx].dylib
# libospray[xxx].0.dylib
# libospray[xxx].[version].dylib
#
# on windows
# libospray[xxx].lib
# libospray[xxx].dll
#
# -- installing headers
IF(VISIT_INSTALL_THIRD_PARTY AND NOT VISIT_HEADERS_SKIP_INSTALL)
INSTALL(DIRECTORY ${OSPRAY_INCLUDE_DIR}/ospray
DESTINATION
DESTINATION ${VISIT_INSTALLED_VERSION_INCLUDE}
FILE_PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_WRITE GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
PATTERN ".svn" EXCLUDE)
ENDIF()
# -- installing libs
IF(NOT VISIT_OSPRAY_SKIP_INSTALL)
FOREACH(l ${OSPRAY_LIBRARIES})
# here because the CMake variable OSPRAY_LIBRARIES contains words
# like 'optimized' and 'debug', we should skip them
IF( (NOT "${l}" STREQUAL "optimized") AND
(NOT "${l}" STREQUAL "debug"))
GET_FILENAME_COMPONENT(_name_ ${l} NAME_WE)
IF( (NOT WIN32) AND
(NOT "${_name_}" STREQUAL "libtbb_debug") AND
(NOT "${_name_}" STREQUAL "libtbbmalloc_debug") AND
(NOT "${_name_}" STREQUAL "libtbb") AND
(NOT "${_name_}" STREQUAL "libtbbmalloc") AND
(NOT "${_name_}" STREQUAL "libembree3") )
THIRD_PARTY_INSTALL_LIBRARY(${l}.0)
ENDIF()
THIRD_PARTY_INSTALL_LIBRARY(${l})
ENDIF()
ENDFOREACH()
ENDIF()

# debug
MESSAGE(STATUS "OSPRAY_INCLUDE_DIR: " ${OSPRAY_INCLUDE_DIR})
MESSAGE(STATUS "OSPRAY_LIBRARIES: " ${OSPRAY_LIBRARIES})
MESSAGE(STATUS "OSPRay for VisIt: ON")

ELSE(VISIT_OSPRAY)
MESSAGE(STATUS "OSPRay for VisIt: OFF")
ENDIF(VISIT_OSPRAY)


96 changes: 1 addition & 95 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1185,103 +1185,9 @@ ELSE(VISIT_THREAD)
MESSAGE(STATUS "Threading for VisIt: OFF")
ENDIF(VISIT_THREAD)

# Enable OSPRay for VisIt
#
# Note by Qi: maybe we should put this section into a .cmake file ?
#
IF(VISIT_OSPRAY)

# -- this is a hack for TBB_ROOT
IF(NOT DEFINED TBB_ROOT)
SET(TBB_ROOT ${VISIT_TBB_ROOT})
ENDIF()
# we have to search for the osprayConfig.cmake file in the ospray install
# folder. Because ospray sometimes install its library in <...>/lib64 folder
# instead of the <...>/lib folder, we have to check both possibilities
IF(EXISTS ${OSPRAY_DIR}/lib)
SET(ospray_DIR ${OSPRAY_DIR}/lib/cmake/ospray-${OSPRAY_VERSION})
ELSEIF(EXISTS ${OSPRAY_DIR}/lib64)
SET(ospray_DIR ${OSPRAY_DIR}/lib64/cmake/ospray-${OSPRAY_VERSION})
ELSE()
MESSAGE(ERROR "Cannot determine ospray_DIR, given OSPRAY_DIR=${OSPRAY_DIR}")
ENDIF()
SET(embree_DIR ${EMBREE_DIR})
MARK_AS_ADVANCED(ospray_DIR)
MARK_AS_ADVANCED(embree_DIR)

# setup ospray
FIND_PACKAGE(ospray REQUIRED)
ADD_DEFINITIONS(-DVISIT_OSPRAY)
INCLUDE_DIRECTORIES(${OSPRAY_INCLUDE_DIR})
LINK_DIRECTORIES(${VISIT_OSPRAY_DIR}/lib)
SET(OSPRAY_LIBRARIES # additional module library
${OSPRAY_LIBRARIES}
${LIBRARY_PATH_PREFIX}ospray_module_ispc${LIBRARY_SUFFIX}
${LIBRARY_PATH_PREFIX}ospray_module_visit${LIBRARY_SUFFIX}
${LIBRARY_PATH_PREFIX}ospray_module_visit_common${LIBRARY_SUFFIX})

# install ospray libs follow visit's standard
#
# -- OSPRAY_LIBRARIES contains also libtbb and libembree, so we dont
# have to handle embree and tbb seperately. As for ISPC, since ISPC
# is only a compiler and will only be needed when we are compiling
# ospray source, we dont have to install ISPC at all here for VisIt.
#
# on linux ospray have libraries in a form of:
# libospray[xxx].so
# libospray[xxx].so.0
# libospray[xxx].so.[version]
#
# on mac ospray have libraries in a form of:
# libospray[xxx].dylib
# libospray[xxx].0.dylib
# libospray[xxx].[version].dylib
#
# on windows
# libospray[xxx].lib
# libospray[xxx].dll
#
# -- installing headers
IF(VISIT_INSTALL_THIRD_PARTY AND NOT VISIT_HEADERS_SKIP_INSTALL)
INSTALL(DIRECTORY ${OSPRAY_INCLUDE_DIR}/ospray
DESTINATION
DESTINATION ${VISIT_INSTALLED_VERSION_INCLUDE}
FILE_PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_WRITE GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
PATTERN ".svn" EXCLUDE)
ENDIF()
# -- installing libs
IF(VISIT_INSTALL_THIRD_PARTY AND NOT VISIT_OSPRAY_SKIP_INSTALL)
FOREACH(l ${OSPRAY_LIBRARIES})
# here because the CMake variable OSPRAY_LIBRARIES contains words
# like 'optimized' and 'debug', we should skip them
IF( (NOT "${l}" STREQUAL "optimized") AND
(NOT "${l}" STREQUAL "debug"))
GET_FILENAME_COMPONENT(_name_ ${l} NAME_WE)
IF( (NOT "${_name_}" STREQUAL "libtbb_debug") AND
(NOT "${_name_}" STREQUAL "libtbbmalloc_debug") AND
(NOT "${_name_}" STREQUAL "libtbb") AND
(NOT "${_name_}" STREQUAL "libtbbmalloc") AND
(NOT "${_name_}" STREQUAL "libembree3") )
THIRD_PARTY_INSTALL_LIBRARY(${l}.0)
ENDIF()
THIRD_PARTY_INSTALL_LIBRARY(${l})
ENDIF()
ENDFOREACH()
ENDIF()

# debug
MESSAGE(STATUS "OSPRAY_INCLUDE_DIR: " ${OSPRAY_INCLUDE_DIR})
MESSAGE(STATUS "OSPRAY_LIBRARIES: " ${OSPRAY_LIBRARIES})
MESSAGE(STATUS "OSPRay for VisIt: ON")
include(${VISIT_SOURCE_DIR}/CMake/FindOSPRay.cmake)

ELSE(VISIT_OSPRAY)
MESSAGE(STATUS "OSPRay for VisIt: OFF")
ENDIF(VISIT_OSPRAY)

#-----------------------------------------------------------------------------
# If we are doing a static build or the VTK Python wrappers do not exist:
Expand Down
5 changes: 4 additions & 1 deletion src/avt/Filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ IF(VISIT_OSPRAY)
avtOSPRaySamplePointExtractor.C
avtOSPRayVoxelExtractor.C
)
ADD_DEFINITIONS(-DVISIT_OSPRAY)
IF(ICET_FOUND)
# If we have Ice-T then add -DHAVE_ICET to the compilation flags.
# We need to link with OpenGL on Mac when we have IceT.
Expand Down Expand Up @@ -199,6 +198,10 @@ ${VTKM_DIR}/include/vtkm-1.2/vtkm/thirdparty/taotuple
${VTK_INCLUDE_DIRS}
)

if(VISIT_OSPRAY)
include_directories(${OSPRAY_INCLUDE_DIR})
endif()

# Add link directories
LINK_DIRECTORIES(${LIBRARY_OUTPUT_DIRECTORY})

Expand Down
8 changes: 0 additions & 8 deletions src/avt/Plotter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,12 @@ TARGET_LINK_LIBRARIES(avtplotter_ser
visitcommon avtmath avtview avtfilters_ser avtpipeline_ser visit_vtk
lightweight_visit_vtk vtkFiltersHybrid vtkRenderingOpenGL2
vtkRenderingFreeType ${OPENGL_LIBRARIES})
IF(VISIT_OSPRAY)
TARGET_LINK_LIBRARIES(avtplotter_ser ${OSPRAY_LIBRARIES})
INCLUDE_DIRECTORIES(${OSPRAY_INCLUDE_DIRS})
ENDIF(VISIT_OSPRAY)
VISIT_INSTALL_TARGETS(avtplotter_ser)

#********************************* PARALLEL **********************************
IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(avtplotter_par ${AVTPLOTTER_SOURCES})
TARGET_LINK_LIBRARIES(avtplotter_par visitcommon avtmath avtview avtfilters_par avtpipeline_par visit_vtk lightweight_visit_vtk vtkFiltersHybrid vtkRenderingOpenGL2 vtkRenderingFreeType ${OPENGL_LIBRARIES})
IF(VISIT_OSPRAY)
TARGET_LINK_LIBRARIES(avtplotter_par ${OSPRAY_LIBRARIES})
INCLUDE_DIRECTORIES(${OSPRAY_INCLUDE_DIRS})
ENDIF(VISIT_OSPRAY)
VISIT_INSTALL_TARGETS(avtplotter_par)
ENDIF(VISIT_PARALLEL)

4 changes: 0 additions & 4 deletions src/plots/Volume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ if(VISIT_SLIVR)
add_definitions(-DVISIT_SLIVR)
endif()

if(VISIT_OSPRAY)
add_definitions(-DVISIT_OSPRAY)
endif()

LINK_DIRECTORIES(${VISIT_LIBRARY_DIR} )

ADD_LIBRARY(IVolumePlot ${LIBI_SOURCES})
Expand Down
1 change: 0 additions & 1 deletion src/plots/Volume/VolumeAttributes.code
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ Definitions: -DVISIT_SLIVR

Target: xml2cmake
Condition: VISIT_OSPRAY
Definitions: -DVISIT_OSPRAY
Includes: ${OSPRAY_INCLUDE_DIR}
VLinkLibraries: ${OSPRAY_LIBRARIES}
ELinkLibraries: ${OSPRAY_LIBRARIES}
Expand Down

0 comments on commit cd96a19

Please sign in to comment.