From e6bd4b5317b14066585417913b578aeb8c1cbfad Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Thu, 22 Aug 2013 18:08:29 -0400 Subject: [PATCH] Only use the PVR loader if the library for loading has been found. --- IO/CMakeLists.txt | 14 +++++++++++--- IO/config/ImageLoader.h.in | 4 ++++ IO/config/ImageWriter.h.in | 4 ++++ IO/src/ImageFile.cpp | 6 +++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/IO/CMakeLists.txt b/IO/CMakeLists.txt index 4572963..41ffd2a 100644 --- a/IO/CMakeLists.txt +++ b/IO/CMakeLists.txt @@ -44,7 +44,6 @@ SET( SOURCES "src/ImageWriter.cpp" "src/ImageLoader.cpp" "src/ImageFile.cpp" - "src/ImageLoaderPVR.cpp" ) SET( HEADERS @@ -52,7 +51,6 @@ SET( HEADERS "config/ImageLoader.h.in" "include/ImageFile.h" "include/FileStream.h" - "src/ImageLoaderPVR.h" ) IF( WIN32 ) @@ -74,6 +72,12 @@ IF( PNG_FOUND ) SET( HEADERS ${HEADERS} "src/ImageWriterPNG.h" ) ENDIF() +IF( PVRTEXLIB_FOUND ) + INCLUDE_DIRECTORIES( ${PVRTEXLIB_INCLUDE_DIRS} ) + SET( SOURCES ${SOURCES} "src/ImageLoaderPVR.cpp" ) + SET( HEADERS ${HEADERS} "src/ImageLoaderPVR.h" ) +ENDIF( PVRTEXLIB_FOUND ) + CONFIGURE_FILE( "config/ImageLoader.h.in" "include/ImageLoader.h" @@ -94,6 +98,10 @@ ADD_LIBRARY(TexCompIO ) IF( PNG_FOUND ) - TARGET_LINK_LIBRARIES( TexCompIO ${PNG_LIBRARY} ) + TARGET_LINK_LIBRARIES( TexCompIO ${PNG_LIBRARY} ) TARGET_LINK_LIBRARIES( TexCompIO ${ZLIB_LIBRARY} ) ENDIF() + +IF( PVRTEXLIB_FOUND ) + TARGET_LINK_LIBRARIES( TexCompIO ${PVRTEXLIB_LIBRARIES} ) +ENDIF() diff --git a/IO/config/ImageLoader.h.in b/IO/config/ImageLoader.h.in index 3c8072d..5654af1 100644 --- a/IO/config/ImageLoader.h.in +++ b/IO/config/ImageLoader.h.in @@ -135,4 +135,8 @@ class ImageLoader { #cmakedefine PNG_FOUND #endif // PNG_FOUND +#ifndef PVRTEXLIB_FOUND +#cmakedefine PVRTEXLIB_FOUND +#endif // PVRTEXLIB_FOUND + #endif // _IMAGE_LOADER_H_ diff --git a/IO/config/ImageWriter.h.in b/IO/config/ImageWriter.h.in index 0c5cb06..e099553 100644 --- a/IO/config/ImageWriter.h.in +++ b/IO/config/ImageWriter.h.in @@ -87,4 +87,8 @@ class ImageWriter { #cmakedefine PNG_FOUND #endif // PNG_FOUND +#ifndef PVRTEXLIB_FOUND +#cmakedefine PVRTEXLIB_FOUND +#endif // PVRTEXLIB_FOUND + #endif // _IMAGE_LOADER_H_ diff --git a/IO/src/ImageFile.cpp b/IO/src/ImageFile.cpp index e2363f7..0fb476c 100644 --- a/IO/src/ImageFile.cpp +++ b/IO/src/ImageFile.cpp @@ -61,7 +61,9 @@ # include "ImageWriterPNG.h" #endif -#include "ImageLoaderPVR.h" +#ifdef PVRTEXLIB_FOUND +# include "ImageLoaderPVR.h" +#endif ////////////////////////////////////////////////////////////////////////////////////////// // @@ -174,9 +176,11 @@ Image *ImageFile::LoadImage(const unsigned char *rawImageData) const { break; #endif // PNG_FOUND +#ifdef PVRTEXLIB_FOUND case eFileFormat_PVR: loader = new ImageLoaderPVR(rawImageData); break; +#endif // PVRTEXLIB_FOUND default: fprintf(stderr, "Unable to load image: unknown file format.\n");