
include_directories( ${OpenLibraries_SOURCE_DIR}/src )
set( NAME openpluginlib_pl )

add_definitions( -DOPENPLUGINLIB_EXPORTS )
if( WIN32 )
   add_definitions( -DOPENPLUGINLIB_LIBNAME=\\\"${NAME}\\\" )
   add_definitions( -DOPENPLUGINLIB_VERSION=\\\"${VERSION_STRING}\\\" )
   add_definitions( -DOPENPLUGINLIB_BUILD )
   set( NAME "${NAME}${LIBRARY_IDENTIFIER}" )
endif( WIN32 )

set( SOURCES
     config.hpp                  
     discovery_traits.hpp        
     fast_math.hpp               
     fast_math.cpp               
     geometry.hpp                
     openplugin.hpp              
     openplugin.cpp              
     openpluginlib.hpp           
     openpluginlib.cpp           
     opl_importer.hpp            
     opl_importer.cpp            
     property.hpp                
     registry.hpp                
     registry.cpp                
     utf8_utils.hpp              
     utf8_utils.cpp              
     opl_parser_action.hpp       
     opl_parser_action.cpp       
     pool.cpp                    
     pool.hpp                    
     string.hpp                  
     allocatorstringstorage.h    
     cowstringopt.h              
     flex_string_details.h       
     flex_string.h               
     flex_string_shell.h         
     simplestringstorage.h       
     smallstringopt.h            
     stream.hpp                  
     stream.cpp                  
     shlib.hpp                   
     shlib.cpp                   
     vectorstringstorage.h       
     GL_utility.hpp              
     GL_utility.cpp              
     cg.hpp                      
     cg.cpp                      
     pcos/key.hpp                
     pcos/key.cpp                
     pcos/observer.hpp           
     pcos/property.hpp           
     pcos/property.cpp           
     pcos/property_container.hpp 
     pcos/property_container.cpp 
     pcos/subject.hpp            
     pcos/subject.cpp            
     pcos/visitor.hpp            
     pcos/isubject.hpp           
     pcos/iclonable.hpp )

set( GLEW_SOURCES 
     bind_info.hpp               
     bind_info.cpp               
     shader_manager.hpp          
     shader_manager.cpp          
     timer.hpp                   
     timer.cpp )

if( GLEW_FOUND )
    set( SOURCES ${SOURCES} ${GLEW_SOURCES} )
endif( GLEW_FOUND )

if( WIN32 )
   set( SOURCES ${SOURCES} content_handler_msxml.cpp content_handler_msxml.hpp )
else( WIN32 )
   set( SOURCES ${SOURCES} content_handler_libxml.cpp content_handler_libxml.hpp )
endif( WIN32 )

install( 
     FILES
     bind_info.hpp               
     discovery_traits.hpp        
     openplugin.hpp              
     openpluginlib.hpp           
     config.hpp                  
     pool.hpp                    
     property.hpp                
     utf8_utils.hpp              
     string.hpp                  
     timer.hpp                   
     shader_manager.hpp          
     geometry.hpp                
     cg.hpp                      
     GL_utility.hpp              
     string.hpp                  
     stream.hpp                  
     DESTINATION "include/${PACKAGE}/openpluginlib/pl" )

install( 
     FILES
     pcos/key.hpp                
     pcos/observer.hpp           
     pcos/iproperty_container.hpp
     pcos/property.hpp           
     pcos/property_container.hpp 
     pcos/subject.hpp            
     pcos/visitor.hpp            
     pcos/isubject.hpp           
     pcos/iclonable.hpp
     DESTINATION "include/${PACKAGE}/openpluginlib/pl/pcos" )

add_library( ${NAME} SHARED ${SOURCES} )
install( TARGETS ${NAME} 
         RUNTIME DESTINATION "lib/${PACKAGE}/openpluginlib/lib"
         ARCHIVE DESTINATION "lib/${PACKAGE}/openpluginlib/lib"
         LIBRARY DESTINATION "lib/${PACKAGE}/openpluginlib/lib" )

if( GLEW_FOUND )
    target_link_libraries( ${NAME} ${GLEW_LIBRARY} )
    target_link_libraries( ${NAME} ${OPENGL_LIBRARIES} )
endif( GLEW_FOUND )

FIND_PACKAGE ( OPENFX )
IF ( OPENFX_FOUND )
    MESSAGE ( "Found libOpenFX: ${OPENFX_INCLUDE_PATH}" )
    INCLUDE_DIRECTORIES ( ${OPENFX_INCLUDE_PATH} )
ENDIF ( OPENFX_FOUND )
