[Bf-blender-cvs] [e0a809f] master: Cycles: Fix compilation error when OIIO is compiled with external PugiXML parser

Sergey Sharybin noreply at git.blender.org
Wed Dec 31 21:32:47 CET 2014


Commit: e0a809fb1d5ff0c79bd8f915bb8660f33ac5c512
Author: Sergey Sharybin
Date:   Sat Nov 15 22:56:22 2014 +0500
Branches: master
https://developer.blender.org/rBe0a809fb1d5ff0c79bd8f915bb8660f33ac5c512

Cycles: Fix compilation error when OIIO is compiled with external PugiXML parser

Basic idea is to check whether OIIO is compiled with embedded PugiXML parser
and if so use PugiXML from OIIO, otherwise find a standalone PugiXML library.

===================================================================

M	CMakeLists.txt
A	build_files/cmake/Modules/FindPugiXML.cmake
M	intern/cycles/CMakeLists.txt
M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/cmake/external_libs.cmake
M	intern/cycles/util/util_xml.h

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1267553..2e7745d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -963,6 +963,12 @@ if(UNIX AND NOT APPLE)
 
 	if(WITH_OPENIMAGEIO)
 		find_package_wrapper(OpenImageIO)
+		if(NOT OPENIMAGEIO_PUGIXML_FOUND AND WITH_CYCLES_STANDALONE)
+			find_package_wrapper(PugiXML)
+		else()
+			set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
+			set(PUGIXML_LIBRARIES "")
+		endif()
 
 		set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
 		set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
diff --git a/build_files/cmake/Modules/FindPugiXML.cmake b/build_files/cmake/Modules/FindPugiXML.cmake
new file mode 100644
index 0000000..b1ed45f
--- /dev/null
+++ b/build_files/cmake/Modules/FindPugiXML.cmake
@@ -0,0 +1,73 @@
+# - Find PugiXML library
+# Find the native PugiXML includes and library
+# This module defines
+#  PUGIXML_INCLUDE_DIRS, where to find pugixml.h, Set when
+#                        PugiXML is found.
+#  PUGIXML_LIBRARIES, libraries to link against to use PugiiXML.
+#  PUGIXML_ROOT_DIR, The base directory to search for PugiXML.
+#                    This can also be an environment variable.
+#  PUGIXML_FOUND, If false, do not try to use PugiXML.
+#
+# also defined, but not for general use are
+#  PUGIXML_LIBRARY, where to find the PugiXML library.
+
+#=============================================================================
+# Copyright 2014 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If PUGIXML_ROOT_DIR was defined in the environment, use it.
+IF(NOT PUGIXML_ROOT_DIR AND NOT $ENV{PUGIXML_ROOT_DIR} STREQUAL "")
+  SET(PUGIXML_ROOT_DIR $ENV{PUGIXML_ROOT_DIR})
+ENDIF()
+
+SET(_pugixml_SEARCH_DIRS
+  ${PUGIXML_ROOT_DIR}
+  /usr/local
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+  /opt/lib/oiio
+)
+
+FIND_PATH(PUGIXML_INCLUDE_DIR
+  NAMES
+    pugixml.h
+  HINTS
+    ${_pugixml_SEARCH_DIRS}
+  PATH_SUFFIXES
+    include
+)
+
+FIND_LIBRARY(PUGIXML_LIBRARY
+  NAMES
+    pugixml
+  HINTS
+    ${_pugixml_SEARCH_DIRS}
+  PATH_SUFFIXES
+    lib64 lib
+  )
+
+# handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PUGIXML DEFAULT_MSG
+    PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
+
+IF(PUGIXML_FOUND)
+  SET(PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
+  SET(PUGIXML_INCLUDE_DIRS ${PUGIXML_INCLUDE_DIR})
+ELSE()
+  SET(PUGIXML_PUGIXML_FOUND FALSE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+  PUGIXML_INCLUDE_DIR
+  PUGIXML_LIBRARY
+)
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 0191201..56deb8d 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -161,6 +161,7 @@ include_directories(
 	${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO
 	${OPENEXR_INCLUDE_DIR}
 	${OPENEXR_INCLUDE_DIRS}
+	${PUGIXML_INCLUDE_DIR}
 )
 
 # TODO(sergey): Adjust so standalone repository is also happy.
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index 3af72ac..0694be0 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -32,6 +32,10 @@ set(LIBRARIES
 	extern_cuew
 )
 
+if(NOT PUGIXML_LIBRARIES STREQUAL "")
+	list(APPEND LIBRARIES ${PUGIXML_LIBRARIES})
+endif()
+
 if(NOT CYCLES_STANDALONE_REPOSITORY)
 	list(APPEND LIBRARIES bf_intern_glew_mx)
 endif()
diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index 7f9a9e0..537de2e 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -66,6 +66,12 @@ if(CYCLES_STANDALONE_REPOSITORY)
 	####
 	# OpenImageIO
 	find_package(OpenImageIO REQUIRED)
+	if(OPENIMAGEIO_PUGIXML_FOUND)
+		set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
+		set(PUGIXML_LIBRARIES "")
+	else()
+		find_package(PugiXML REQUIRED)
+	endif()
 
 	# OIIO usually depends on OpenEXR, so find this library
 	# but don't make it required.
@@ -75,10 +81,12 @@ if(CYCLES_STANDALONE_REPOSITORY)
 	# Boost
 	set(__boost_packages filesystem regex system thread date_time)
 	if(WITH_CYCLES_NETWORK)
-	       list(APPEND __boost_packages serialization)
+		list(APPEND __boost_packages serialization)
 	endif()
 	if(WITH_CYCLES_OSL AND APPLE)
-	       list(APPEND __boost_packages wave)
+		# TODO(sergey): This is because of the way how our precompiled
+		# libraries works, could be different for someone's else libs..
+		list(APPEND __boost_packages wave)
 	endif()
 	find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED)
 	if(NOT Boost_FOUND)
diff --git a/intern/cycles/util/util_xml.h b/intern/cycles/util/util_xml.h
index d1b4ee1..cfd0afc 100644
--- a/intern/cycles/util/util_xml.h
+++ b/intern/cycles/util/util_xml.h
@@ -17,9 +17,9 @@
 #ifndef __UTIL_XML_H__
 #define __UTIL_XML_H__
 
-/* PugiXML from OpenImageIO is used for XML parsing. */
+/* PugiXML is used for XML parsing. */
 
-#include <OpenImageIO/pugixml.hpp>
+#include <pugixml.hpp>
 
 CCL_NAMESPACE_BEGIN




More information about the Bf-blender-cvs mailing list