From 5e8140a14f1b25c57f761a7985c005fc65536aa8 Mon Sep 17 00:00:00 2001 From: Nick Porcino Date: Thu, 2 Aug 2018 23:57:29 -0700 Subject: [PATCH] PR #187 CMake enhancements to speed up dependency builds of OpenEXR. --- CMakeLists.txt | 32 ++++++++++++------- IlmBase/CMakeLists.txt | 4 +++ IlmBase/Imath/CMakeLists.txt | 2 -- IlmBase/Imath/ImathBox.cpp | 37 ---------------------- IlmBase/Imath/ImathMatrix.h | 8 ++--- IlmBase/Imath/ImathShear.cpp | 54 -------------------------------- IlmBase/Imath/Makefile.am | 4 +-- PyIlmBase/PyImath/CMakeLists.txt | 6 ++-- 8 files changed, 34 insertions(+), 113 deletions(-) delete mode 100644 IlmBase/Imath/ImathBox.cpp delete mode 100644 IlmBase/Imath/ImathShear.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 05fe6720..e67c9d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,16 +20,17 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # The following user options are cached. They are named with the OPENEXR # prefix in order that they be grouped together in tools such as ccmake and cmake-gui. -option(OPENEXR_BUILD_ILMBASE "Build IlmBase" ON) -option(OPENEXR_BUILD_OPENEXR "Build OpenEXR" ON) -option(OPENEXR_BUILD_PYTHON_LIBS "Build the Python bindings" ON) -option(OPENEXR_BUILD_VIEWERS "Build the viewers" OFF) -option(OPENEXR_BUILD_TESTS "Enable the tests" ON) - -option(OPENEXR_BUILD_SHARED "Build Shared Libraries" ON) -option(OPENEXR_BUILD_STATIC "Build Static Libraries" OFF) -option(OPENEXR_NAMESPACE_VERSIONING "Use Namespace Versioning" ON) -option(OPENEXR_FORCE_CXX03 "Force CXX03" OFF) +option(OPENEXR_BUILD_ILMBASE "Build IlmBase" ON) +option(OPENEXR_BUILD_OPENEXR "Build OpenEXR" ON) +option(OPENEXR_BUILD_PYTHON_LIBS "Build the Python bindings" ON) +option(OPENEXR_BUILD_VIEWERS "Build the viewers" OFF) +option(OPENEXR_BUILD_TESTS "Enable the tests" ON) +option(OPENEXR_BUILD_UTILS "Build the utility programs" ON) + +option(OPENEXR_BUILD_SHARED "Build Shared Libraries" ON) +option(OPENEXR_BUILD_STATIC "Build Static Libraries" OFF) +option(OPENEXR_NAMESPACE_VERSIONING "Use Namespace Versioning" ON) +option(OPENEXR_FORCE_CXX03 "Force CXX03" OFF) set(OPENEXR_PYTHON_MAJOR "2" CACHE STRING "Python major version") set(OPENEXR_PYTHON_MINOR "7" CACHE STRING "Python minor version") @@ -144,7 +145,7 @@ if(OPENEXR_BUILD_VIEWERS) endif() endif() -if ((OPENEXR_BUILD_OPENEXR OR OPENEXR_BUILD_PYTHON_LIBS OR OPENEXR_BUILD_VIEWERS) AND NOT(OPENEXR_BUILD_ILMBASE)) +if ((OPENEXR_BUILD_OPENEXR OR OPENEXR_BUILD_UTILS OR OPENEXR_BUILD_TESTS OR OPENEXR_BUILD_PYTHON_LIBS OR OPENEXR_BUILD_VIEWERS) AND NOT(OPENEXR_BUILD_ILMBASE)) message(INFO "OPENEXR_BUILD_ILMBASE not requested, searching for installed IlmBase instead") find_package(IlmBase) if (NOT IlmBase_FOUND) @@ -153,6 +154,15 @@ if ((OPENEXR_BUILD_OPENEXR OR OPENEXR_BUILD_PYTHON_LIBS OR OPENEXR_BUILD_VIEWERS endif() endif() +if ((OPENEXR_BUILD_UTILS OR OPENEXR_BUILD_TESTS OR OPENEXR_BUILD_VIEWERS) AND NOT(OPENEXR_BUILD_OPENEXR)) + message(INFO "OPENEXR_BUILD_OPENEXR not requested, searching for installed OpenEXR instead") + find_package(OpenEXR) + if (NOT OpenEXR_FOUND) + message(ERROR "Could not find OpenEXR, cannot build dependent libraries.") + message(INFO, "Set OPENEXR_LOCATION to location of OpenEXR.") + endif() +endif() + # Perform the build if(OPENEXR_BUILD_ILMBASE) add_subdirectory(IlmBase) diff --git a/IlmBase/CMakeLists.txt b/IlmBase/CMakeLists.txt index 90fb67b9..49fa05c1 100644 --- a/IlmBase/CMakeLists.txt +++ b/IlmBase/CMakeLists.txt @@ -18,6 +18,10 @@ INCLUDE_DIRECTORIES ( Iex IexMath Imath Half IlmThread IexTest ImathTest HalfTest ${CMAKE_CURRENT_BINARY_DIR}/config ) +IF(WIN32) + SET(CMAKE_DEBUG_POSTFIX "_d") +ENDIF() + # also add the current directory to pick up the autogenerated headers SET(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/IlmBase/Imath/CMakeLists.txt b/IlmBase/Imath/CMakeLists.txt index 19c3c5a2..e5c30025 100644 --- a/IlmBase/Imath/CMakeLists.txt +++ b/IlmBase/Imath/CMakeLists.txt @@ -3,10 +3,8 @@ SET (ILMBASE_LIB_TARGETS "") SET ( IMATH_SOURCES - ImathBox.cpp ImathRandom.cpp ImathColorAlgo.cpp - ImathShear.cpp ImathFun.cpp ImathVec.cpp ImathMatrixAlgo.cpp diff --git a/IlmBase/Imath/ImathBox.cpp b/IlmBase/Imath/ImathBox.cpp deleted file mode 100644 index 07bddfd3..00000000 --- a/IlmBase/Imath/ImathBox.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas -// Digital Ltd. LLC -// -// All rights reserved. -// -// 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 following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Industrial Light & Magic 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 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. -// -/////////////////////////////////////////////////////////////////////////// - -#include "ImathBox.h" - -// this file is necessary for template instantiation on windows diff --git a/IlmBase/Imath/ImathMatrix.h b/IlmBase/Imath/ImathMatrix.h index c5d7e244..5729c734 100644 --- a/IlmBase/Imath/ImathMatrix.h +++ b/IlmBase/Imath/ImathMatrix.h @@ -3244,13 +3244,13 @@ operator << (std::ostream &s, const Matrix33 &m) if (s.flags() & std::ios_base::fixed) { s.setf (std::ios_base::showpoint); - width = s.precision() + 5; + width = static_cast(s.precision()) + 5; } else { s.setf (std::ios_base::scientific); s.setf (std::ios_base::showpoint); - width = s.precision() + 8; + width = static_cast(s.precision()) + 8; } s << "(" << std::setw (width) << m[0][0] << @@ -3279,13 +3279,13 @@ operator << (std::ostream &s, const Matrix44 &m) if (s.flags() & std::ios_base::fixed) { s.setf (std::ios_base::showpoint); - width = s.precision() + 5; + width = static_cast(s.precision()) + 5; } else { s.setf (std::ios_base::scientific); s.setf (std::ios_base::showpoint); - width = s.precision() + 8; + width = static_cast(s.precision()) + 8; } s << "(" << std::setw (width) << m[0][0] << diff --git a/IlmBase/Imath/ImathShear.cpp b/IlmBase/Imath/ImathShear.cpp deleted file mode 100644 index 2c0ba2ae..00000000 --- a/IlmBase/Imath/ImathShear.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2002-2012, Industrial Light & Magic, a division of Lucas -// Digital Ltd. LLC -// -// All rights reserved. -// -// 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 following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Industrial Light & Magic 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 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. -// -/////////////////////////////////////////////////////////////////////////// - - - - -//---------------------------------------------------------------------------- -// -// Specializations of the Shear6 template. -// -//---------------------------------------------------------------------------- - -#include "ImathShear.h" - -IMATH_INTERNAL_NAMESPACE_SOURCE_ENTER - - - -// empty - - - -IMATH_INTERNAL_NAMESPACE_SOURCE_EXIT diff --git a/IlmBase/Imath/Makefile.am b/IlmBase/Imath/Makefile.am index 8d3fe9b5..8f4e801f 100644 --- a/IlmBase/Imath/Makefile.am +++ b/IlmBase/Imath/Makefile.am @@ -2,7 +2,7 @@ lib_LTLIBRARIES = libImath.la -libImath_la_SOURCES = ImathShear.cpp ImathMatrixAlgo.cpp ImathVec.cpp \ +libImath_la_SOURCES = ImathMatrixAlgo.cpp ImathVec.cpp \ ImathColorAlgo.cpp ImathFun.cpp \ ImathColorAlgo.h ImathMatrixAlgo.h ImathVec.h \ ImathShear.h ImathFun.h ImathBox.h ImathBoxAlgo.h \ @@ -13,7 +13,7 @@ libImath_la_SOURCES = ImathShear.cpp ImathMatrixAlgo.cpp ImathVec.cpp \ ImathColor.h ImathRandom.h ImathRoots.h \ ImathHalfLimits.h ImathInterval.h ImathGLU.h \ ImathFrame.h ImathPlatform.h \ - ImathBox.cpp ImathRandom.cpp ImathInt64.h \ + ImathRandom.cpp ImathInt64.h \ ImathFrustumTest.h libImath_la_LDFLAGS = -version-info @LIBTOOL_VERSION@ -no-undefined diff --git a/PyIlmBase/PyImath/CMakeLists.txt b/PyIlmBase/PyImath/CMakeLists.txt index 1fc9e55f..44cf4138 100644 --- a/PyIlmBase/PyImath/CMakeLists.txt +++ b/PyIlmBase/PyImath/CMakeLists.txt @@ -68,18 +68,18 @@ ADD_LIBRARY ( imathmodule ${LIB_TYPE} PyImathBasicTypes.cpp ) -if (WIN32) +IF (WIN32) SET_TARGET_PROPERTIES ( imathmodule PROPERTIES PREFIX "" OUTPUT_NAME "imath" SUFFIX ".pyd" ) -else() +ELSE () SET_TARGET_PROPERTIES ( imathmodule PROPERTIES PREFIX "" SUFFIX ".so" BUILD_WITH_INSTALL_RPATH ON ) -endif() +ENDIF () SET_ILMBASE_INCLUDE_DIRS( imathmodule )