Only use the PVR loader if the library for loading has been found.

This commit is contained in:
Pavel Krajcevski 2013-08-22 18:08:29 -04:00
parent 07e9c2c531
commit e6bd4b5317
4 changed files with 24 additions and 4 deletions

View file

@ -44,7 +44,6 @@ SET( SOURCES
"src/ImageWriter.cpp" "src/ImageWriter.cpp"
"src/ImageLoader.cpp" "src/ImageLoader.cpp"
"src/ImageFile.cpp" "src/ImageFile.cpp"
"src/ImageLoaderPVR.cpp"
) )
SET( HEADERS SET( HEADERS
@ -52,7 +51,6 @@ SET( HEADERS
"config/ImageLoader.h.in" "config/ImageLoader.h.in"
"include/ImageFile.h" "include/ImageFile.h"
"include/FileStream.h" "include/FileStream.h"
"src/ImageLoaderPVR.h"
) )
IF( WIN32 ) IF( WIN32 )
@ -74,6 +72,12 @@ IF( PNG_FOUND )
SET( HEADERS ${HEADERS} "src/ImageWriterPNG.h" ) SET( HEADERS ${HEADERS} "src/ImageWriterPNG.h" )
ENDIF() 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( CONFIGURE_FILE(
"config/ImageLoader.h.in" "config/ImageLoader.h.in"
"include/ImageLoader.h" "include/ImageLoader.h"
@ -97,3 +101,7 @@ IF( PNG_FOUND )
TARGET_LINK_LIBRARIES( TexCompIO ${PNG_LIBRARY} ) TARGET_LINK_LIBRARIES( TexCompIO ${PNG_LIBRARY} )
TARGET_LINK_LIBRARIES( TexCompIO ${ZLIB_LIBRARY} ) TARGET_LINK_LIBRARIES( TexCompIO ${ZLIB_LIBRARY} )
ENDIF() ENDIF()
IF( PVRTEXLIB_FOUND )
TARGET_LINK_LIBRARIES( TexCompIO ${PVRTEXLIB_LIBRARIES} )
ENDIF()

View file

@ -135,4 +135,8 @@ class ImageLoader {
#cmakedefine PNG_FOUND #cmakedefine PNG_FOUND
#endif // PNG_FOUND #endif // PNG_FOUND
#ifndef PVRTEXLIB_FOUND
#cmakedefine PVRTEXLIB_FOUND
#endif // PVRTEXLIB_FOUND
#endif // _IMAGE_LOADER_H_ #endif // _IMAGE_LOADER_H_

View file

@ -87,4 +87,8 @@ class ImageWriter {
#cmakedefine PNG_FOUND #cmakedefine PNG_FOUND
#endif // PNG_FOUND #endif // PNG_FOUND
#ifndef PVRTEXLIB_FOUND
#cmakedefine PVRTEXLIB_FOUND
#endif // PVRTEXLIB_FOUND
#endif // _IMAGE_LOADER_H_ #endif // _IMAGE_LOADER_H_

View file

@ -61,7 +61,9 @@
# include "ImageWriterPNG.h" # include "ImageWriterPNG.h"
#endif #endif
#include "ImageLoaderPVR.h" #ifdef PVRTEXLIB_FOUND
# include "ImageLoaderPVR.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// //
@ -174,9 +176,11 @@ Image *ImageFile::LoadImage(const unsigned char *rawImageData) const {
break; break;
#endif // PNG_FOUND #endif // PNG_FOUND
#ifdef PVRTEXLIB_FOUND
case eFileFormat_PVR: case eFileFormat_PVR:
loader = new ImageLoaderPVR(rawImageData); loader = new ImageLoaderPVR(rawImageData);
break; break;
#endif // PVRTEXLIB_FOUND
default: default:
fprintf(stderr, "Unable to load image: unknown file format.\n"); fprintf(stderr, "Unable to load image: unknown file format.\n");