From cf84b7a346944c5114921b89488638d592bf3183 Mon Sep 17 00:00:00 2001 From: Yasin Hasanian Date: Fri, 8 Nov 2019 00:34:39 -0800 Subject: [PATCH] compile fixes (on mac) --- CMakeLists.txt | 16 +- cmake/FindIlmBase.cmake | 352 ++++++++++++++++++++++++++++++++++ cmake/FindMaya.cmake | 6 +- plugin/CMakeLists.txt | 9 +- plugin/vdb_sliced_display.cpp | 15 +- 5 files changed, 377 insertions(+), 21 deletions(-) create mode 100644 cmake/FindIlmBase.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fc659cb..0bf8d2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,27 +6,29 @@ if (UNIX AND NOT APPLE) endif () option(BUILD_MAYA_PLUGIN "Build the maya plugin." ON) -option(BUILD_MTOA_EXTENSION "Build the MtoA extension." ON) -option(BUILD_ARNOLD_SHADER "Build the Arnold shader." ON) -option(BUILD_USD_TOOLS "Build the various USD tools." ON) -option(USE_CUDA "Use CUDA." ON) +option(BUILD_MTOA_EXTENSION "Build the MtoA extension." OFF) +option(BUILD_ARNOLD_SHADER "Build the Arnold shader." OFF) +option(BUILD_USD_TOOLS "Build the various USD tools." OFF) +option(USE_CUDA "Use CUDA." OFF) option(INCLUDE_HEADERS_IN_BUILD "Include the headers next to the source files for IDEs that need this." ON) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +set(CMAKE_MACOSX_RPATH 1) + set(CMAKE_CXX_STANDARD 11) if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOSMac_ -Wall -Wextra -fPIC") # with gcc-6, we get this warning/error: # openvdb/math/Coord.h:372:52: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow] # bool empty() const { return (mMin[0] > mMax[0] || mMin[1] > mMax[1] || mMin[2] > mMax[2]); } # ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ # This didn't make a lot of sense to me, but not taking the time to figure - # this out, and just disabling the error for now... - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=strict-overflow") + # this out, and just disabling the error for now...f + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=strict-overflow -Wno-unused-private-field -Wno-unused-value -Wno-unused-function -Wno-deprecated-declarations") endif () if (WIN32) diff --git a/cmake/FindIlmBase.cmake b/cmake/FindIlmBase.cmake new file mode 100644 index 0000000..aa9d982 --- /dev/null +++ b/cmake/FindIlmBase.cmake @@ -0,0 +1,352 @@ +# Copyright (c) DreamWorks Animation LLC +# +# All rights reserved. This software is distributed under the +# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) +# +# Redistributions of source code must retain the above copyright +# and license notice and the following restrictions and disclaimer. +# +# * Neither the name of DreamWorks Animation 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 THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 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. +# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE +# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. +# +#[=======================================================================[.rst: + +FindIlmBase +----------- + +Find IlmBase include dirs and libraries + +Use this module by invoking find_package with the form:: + + find_package(IlmBase + [version] [EXACT] # Minimum or EXACT version + [REQUIRED] # Fail with error if IlmBase is not found + [COMPONENTS ...] # IlmBase libraries by their canonical name + # e.g. "Half" for "libHalf" + ) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +``IlmBase::Half`` + The Half library target. +``IlmBase::Iex`` + The Iex library target. +``IlmBase::IexMath`` + The IexMath library target. +``IlmBase::IlmThread`` + The IlmThread library target. +``IlmBase::Imath`` + The Imath library target. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``IlmBase_FOUND`` + True if the system has the IlmBase library. +``IlmBase_VERSION`` + The version of the IlmBase library which was found. +``IlmBase_INCLUDE_DIRS`` + Include directories needed to use IlmBase. +``IlmBase_LIBRARIES`` + Libraries needed to link to IlmBase. +``IlmBase_LIBRARY_DIRS`` + IlmBase library directories. +``IlmBase_{COMPONENT}_FOUND`` + True if the system has the named IlmBase component. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``IlmBase_INCLUDE_DIR`` + The directory containing ``IlmBase/config-auto.h``. +``IlmBase_{COMPONENT}_LIBRARY`` + Individual component libraries for IlmBase +``IlmBase_{COMPONENT}_DLL`` + Individual component dlls for IlmBase on Windows. + +Hints +^^^^^ + +Instead of explicitly setting the cache variables, the following variables +may be provided to tell this module where to look. + +``IlmBase_ROOT`` + Preferred installation prefix. +``ILMBASE_INCLUDEDIR`` + Preferred include directory e.g. /include +``ILMBASE_LIBRARYDIR`` + Preferred library directory e.g. /lib +``SYSTEM_LIBRARY_PATHS`` + Global list of library paths intended to be searched by and find_xxx call +``ILMBASE_USE_STATIC_LIBS`` + Only search for static ilmbase libraries +``DISABLE_CMAKE_SEARCH_PATHS`` + Disable CMakes default search paths for find_xxx calls in this module + +#]=======================================================================] + +cmake_minimum_required(VERSION 3.3) + +# Monitoring _ROOT variables +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() + +mark_as_advanced( + IlmBase_INCLUDE_DIR + IlmBase_LIBRARY +) + +set(_FIND_ILMBASE_ADDITIONAL_OPTIONS "") +if(DISABLE_CMAKE_SEARCH_PATHS) + set(_FIND_ILMBASE_ADDITIONAL_OPTIONS NO_DEFAULT_PATH) +endif() + +set(_ILMBASE_COMPONENT_LIST + Half + Iex + IexMath + IlmThread + Imath +) + +if(IlmBase_FIND_COMPONENTS) + set(ILMBASE_COMPONENTS_PROVIDED TRUE) + set(_IGNORED_COMPONENTS "") + foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + if(NOT ${COMPONENT} IN_LIST _ILMBASE_COMPONENT_LIST) + list(APPEND _IGNORED_COMPONENTS ${COMPONENT}) + endif() + endforeach() + + if(_IGNORED_COMPONENTS) + message(STATUS "Ignoring unknown components of IlmBase:") + foreach(COMPONENT ${_IGNORED_COMPONENTS}) + message(STATUS " ${COMPONENT}") + endforeach() + list(REMOVE_ITEM IlmBase_FIND_COMPONENTS ${_IGNORED_COMPONENTS}) + endif() +else() + set(ILMBASE_COMPONENTS_PROVIDED FALSE) + set(IlmBase_FIND_COMPONENTS ${_ILMBASE_COMPONENT_LIST}) +endif() + +# Set _ILMBASE_ROOT based on a user provided root var. Xxx_ROOT and ENV{Xxx_ROOT} +# are prioritised over the legacy capitalized XXX_ROOT variables for matching +# CMake 3.12 behaviour +# @todo deprecate -D and ENV ILMBASE_ROOT from CMake 3.12 +if(IlmBase_ROOT) + set(_ILMBASE_ROOT ${IlmBase_ROOT}) +elseif(DEFINED ENV{IlmBase_ROOT}) + set(_ILMBASE_ROOT $ENV{IlmBase_ROOT}) +elseif(ILMBASE_ROOT) + set(_ILMBASE_ROOT ${ILMBASE_ROOT}) +elseif(DEFINED ENV{ILMBASE_ROOT}) + set(_ILMBASE_ROOT $ENV{ILMBASE_ROOT}) +endif() + +# Additionally try and use pkconfig to find IlmBase + +if(NOT DEFINED PKG_CONFIG_FOUND) + find_package(PkgConfig) +endif() +pkg_check_modules(PC_IlmBase QUIET IlmBase) + +# ------------------------------------------------------------------------ +# Search for IlmBase include DIR +# ------------------------------------------------------------------------ + +set(_ILMBASE_INCLUDE_SEARCH_DIRS "") +list(APPEND _ILMBASE_INCLUDE_SEARCH_DIRS + ${ILMBASE_INCLUDEDIR} + ${_ILMBASE_ROOT} + ${PC_IlmBase_INCLUDEDIR} + ${SYSTEM_LIBRARY_PATHS} +) + +# Look for a standard IlmBase header file. +find_path(IlmBase_INCLUDE_DIR IlmBaseConfig.h + ${_FIND_ILMBASE_ADDITIONAL_OPTIONS} + PATHS ${_ILMBASE_INCLUDE_SEARCH_DIRS} + PATH_SUFFIXES include/OpenEXR OpenEXR +) + +if(EXISTS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h") + # Get the ILMBASE version information from the config header + file(STRINGS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h" + _ilmbase_version_major_string REGEX "#define ILMBASE_VERSION_MAJOR " + ) + string(REGEX REPLACE "#define ILMBASE_VERSION_MAJOR" "" + _ilmbase_version_major_string "${_ilmbase_version_major_string}" + ) + string(STRIP "${_ilmbase_version_major_string}" IlmBase_VERSION_MAJOR) + + file(STRINGS "${IlmBase_INCLUDE_DIR}/IlmBaseConfig.h" + _ilmbase_version_minor_string REGEX "#define ILMBASE_VERSION_MINOR " + ) + string(REGEX REPLACE "#define ILMBASE_VERSION_MINOR" "" + _ilmbase_version_minor_string "${_ilmbase_version_minor_string}" + ) + string(STRIP "${_ilmbase_version_minor_string}" IlmBase_VERSION_MINOR) + + unset(_ilmbase_version_major_string) + unset(_ilmbase_version_minor_string) + + set(IlmBase_VERSION ${IlmBase_VERSION_MAJOR}.${IlmBase_VERSION_MINOR}) +endif() + +# ------------------------------------------------------------------------ +# Search for ILMBASE lib DIR +# ------------------------------------------------------------------------ + +set(_ILMBASE_LIBRARYDIR_SEARCH_DIRS "") + +# Append to _ILMBASE_LIBRARYDIR_SEARCH_DIRS in priority order + +list(APPEND _ILMBASE_LIBRARYDIR_SEARCH_DIRS + ${ILMBASE_LIBRARYDIR} + ${_ILMBASE_ROOT} + ${PC_IlmBase_LIBDIR} + ${SYSTEM_LIBRARY_PATHS} +) + +# Build suffix directories + +set(ILMBASE_PATH_SUFFIXES + lib64 + lib +) + +if(UNIX) + list(INSERT ILMBASE_PATH_SUFFIXES 0 lib/x86_64-linux-gnu) +endif() + +set(_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + +# library suffix handling +if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES + "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.lib" + ) +else() + if(ILMBASE_USE_STATIC_LIBS) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES + "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.a" + ) + else() + if(APPLE) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES + "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.dylib" + ) + else() + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES + "-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.so" + ) + endif() + endif() +endif() + +set(IlmBase_LIB_COMPONENTS "") + +foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + find_library(IlmBase_${COMPONENT}_LIBRARY ${COMPONENT} + ${_FIND_ILMBASE_ADDITIONAL_OPTIONS} + PATHS ${_ILMBASE_LIBRARYDIR_SEARCH_DIRS} + PATH_SUFFIXES ${ILMBASE_PATH_SUFFIXES} + ) + list(APPEND IlmBase_LIB_COMPONENTS ${IlmBase_${COMPONENT}_LIBRARY}) + + if(WIN32 AND NOT ILMBASE_USE_STATIC_LIBS) + set(_ILMBASE_TMP ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") + find_library(IlmBase_${COMPONENT}_DLL ${COMPONENT} + ${_FIND_ILMBASE_ADDITIONAL_OPTIONS} + PATHS ${_ILMBASE_LIBRARYDIR_SEARCH_DIRS} + PATH_SUFFIXES bin + ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ILMBASE_TMP}) + unset(_ILMBASE_TMP) + endif() + + if(IlmBase_${COMPONENT}_LIBRARY) + set(IlmBase_${COMPONENT}_FOUND TRUE) + else() + set(IlmBase_${COMPONENT}_FOUND FALSE) + endif() +endforeach() + +# reset lib suffix + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +unset(_ILMBASE_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + +# ------------------------------------------------------------------------ +# Cache and set ILMBASE_FOUND +# ------------------------------------------------------------------------ + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(IlmBase + FOUND_VAR IlmBase_FOUND + REQUIRED_VARS + IlmBase_INCLUDE_DIR + IlmBase_LIB_COMPONENTS + VERSION_VAR IlmBase_VERSION + HANDLE_COMPONENTS +) + +if(IlmBase_FOUND) + set(IlmBase_LIBRARIES ${IlmBase_LIB_COMPONENTS}) + + # We have to add both include and include/OpenEXR to the include + # path in case OpenEXR and IlmBase are installed separately + + set(IlmBase_INCLUDE_DIRS) + list(APPEND IlmBase_INCLUDE_DIRS + ${IlmBase_INCLUDE_DIR}/../ + ${IlmBase_INCLUDE_DIR} + ) + set(IlmBase_DEFINITIONS ${PC_IlmBase_CFLAGS_OTHER}) + + set(IlmBase_LIBRARY_DIRS "") + foreach(LIB ${IlmBase_LIB_COMPONENTS}) + get_filename_component(_ILMBASE_LIBDIR ${LIB} DIRECTORY) + list(APPEND IlmBase_LIBRARY_DIRS ${_ILMBASE_LIBDIR}) + endforeach() + list(REMOVE_DUPLICATES IlmBase_LIBRARY_DIRS) + + # Configure imported targets + + foreach(COMPONENT ${IlmBase_FIND_COMPONENTS}) + if(NOT TARGET IlmBase::${COMPONENT}) + add_library(IlmBase::${COMPONENT} UNKNOWN IMPORTED) + set_target_properties(IlmBase::${COMPONENT} PROPERTIES + IMPORTED_LOCATION "${IlmBase_${COMPONENT}_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${IlmBase_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${IlmBase_INCLUDE_DIRS}" + ) + endif() + endforeach() + +elseif(IlmBase_FIND_REQUIRED) + message(FATAL_ERROR "Unable to find IlmBase") +endif() diff --git a/cmake/FindMaya.cmake b/cmake/FindMaya.cmake index cb48213..202628c 100644 --- a/cmake/FindMaya.cmake +++ b/cmake/FindMaya.cmake @@ -90,8 +90,8 @@ endmacro(MAYA_SET_PLUGIN_PROPERTIES) #SET(MAYA_FOUND FALSE) -set(_maya_TEST_VERSIONS) -set(_maya_KNOWN_VERSIONS "2008" "2009" "2010" "2011" "2012" "2013" "2014" "2015" "2016" "2017" "2018") +set(_maya_TEST_VERSIONS "2018") +set(_maya_KNOWN_VERSIONS "2016" "2017" "2018") if(APPLE) set(MAYA_PLUGIN_SUFFIX ".bundle") @@ -229,7 +229,7 @@ FIND_PATH(MAYA_DEVKIT_INC_DIR GL/glext.h ${MAYA_LOCATION} $ENV{DEVKIT_LOCATION} PATH_SUFFIXES - devkit/plug-ins/ # linux + devkit/plug-ins # linux ../../devkit/plug-ins # osx DOC "Maya's devkit headers path" ) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index ea03a8f..259fe01 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -12,7 +12,9 @@ if (USE_CUDA) find_package(CUDA) endif () find_package(Maya) -find_package(Boost COMPONENTS regex) +find_package(Boost COMPONENTS regex iostreams) +find_package(TBB REQUIRED) +find_package(IlmBase REQUIRED) if (NOT ILMBASE_ROOT) set(ILMBASE_ROOT $ENV{ILMBASE_ROOT}) @@ -24,7 +26,8 @@ find_path(OPENVDB_INCLUDE include_directories(${LUMA_NODE_ID_INCLUDE}) include_directories(${OPENVDB_INCLUDE}) include_directories(${Boost_INCLUDE_DIRS}) -include_directories(SYSTEM ${ILMBASE_ROOT}/include) #register is deprecated with c++11 +include_directories(SYSTEM ${TBB_INCLUDE_DIRS}) +include_directories(SYSTEM ${IlmBase_INCLUDE_DIRS}) #register is deprecated with c++11 include_directories(${MAYA_INCLUDE_DIRS}) link_directories(${MAYA_LIBRARY_DIR}) @@ -64,7 +67,7 @@ if (WIN32) set_target_properties(${PLUGIN_NAME} PROPERTIES SUFFIX ".mll") endif () -target_link_libraries(${PLUGIN_NAME} ${OPENGL_gl_LIBRARY} ${MAYA_LIBS} ${OPENVDB_STATIC_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(${PLUGIN_NAME} ${OPENGL_gl_LIBRARY} ${TBB_LIBRARIES} ${IlmBase_LIBRARIES} ${MAYA_LIBS} ${OPENVDB_STATIC_LIBRARY} ${Boost_LIBRARIES} ) if (USE_CUDA) target_link_libraries(${PLUGIN_NAME} ${CUDA_STATIC_LIBRARIES}) endif () diff --git a/plugin/vdb_sliced_display.cpp b/plugin/vdb_sliced_display.cpp index d1d3eaa..3e1349b 100644 --- a/plugin/vdb_sliced_display.cpp +++ b/plugin/vdb_sliced_display.cpp @@ -124,13 +124,13 @@ namespace std { return res; } }; +} - bool operator==(const VDBVolumeSpec& lhs, const VDBVolumeSpec& rhs) - { - return lhs.vdb_file_name == rhs.vdb_file_name && - lhs.vdb_grid_name == rhs.vdb_grid_name && - lhs.texture_size == rhs.texture_size; - } +bool operator==(const VDBVolumeSpec& lhs, const VDBVolumeSpec& rhs) +{ + return lhs.vdb_file_name == rhs.vdb_file_name && + lhs.vdb_grid_name == rhs.vdb_grid_name && + lhs.texture_size == rhs.texture_size; } // === SamplerState ======================================================== @@ -1882,7 +1882,6 @@ class VDBSlicedDisplayImpl { SamplerStatePtr m_volume_sampler_state; bool m_enabled; - bool m_selected; }; @@ -1893,7 +1892,7 @@ VDBSlicedDisplayImpl::VDBSlicedDisplayImpl(MHWRender::MPxSubSceneOverride& paren , m_density_channel("density"), m_scattering_channel("scattering"), m_emission_channel("emission"), m_transparency_channel("transparency"), m_temperature_channel("temperature") , m_density_ramp(RAMP_RESOLUTION), m_scattering_ramp(RAMP_RESOLUTION), m_emission_ramp(RAMP_RESOLUTION) , m_volume_sampler_state(createSamplerState(MHWRender::MSamplerState::kMinMagMipLinear, MHWRender::MSamplerState::kTexBorder)) - , m_enabled(false), m_selected(false) + , m_enabled(false) { if (!m_volume_shader) return;