
set( _any_gpgme_found false )

set( _qgpgme_version 1.0.1 )
set( _qgpgme_soversion 1 )

if ( WIN32 AND GPGME_VANILLA_FOUND )

   # on Windows, we require gpgme(-vanilla), which is thread-safe,
   # and we don't provide gpgme-qt support

   set( _any_gpgme_found true )
   set( _qgpgme_libgpgme gpgmepp )
   #set( _qgpgme_extra_src eventloopinteractor_win.cpp )

endif ( WIN32 AND GPGME_VANILLA_FOUND )

if ( NOT WIN32 AND GPGME_PTHREAD_FOUND )

   # on Unix, we requrie gpgme-pthread (for convenience, since vanilla
   # gpgme isn't thread-aware, and we don't want to restrict clients
   # of qgpgme to non-threaded useage of gpgme)

   set( _any_gpgme_found true )
   set( _qgpgme_libgpgme gpgmepp-pthread )
   set( _qgpgme_extra_src eventloopinteractor.cpp eventloopinteractor_unix.cpp )
   set( _qgpgme_extra_headers eventloopinteractor.h )

endif ( NOT WIN32 AND GPGME_PTHREAD_FOUND )

# build / install only if any useable gpgme was found:

if ( _any_gpgme_found )

   include_directories( ${GPGME_INCLUDES} ${CMAKE_SOURCE_DIR}/gpgme++ ${Boost_INCLUDE_DIR} )

   add_subdirectory( tests )

   set( qgpgme_LIB_SRCS
        dataprovider.cpp
        ${_qgpgme_extra_src}
   )

   kde4_add_library( qgpgme SHARED ${qgpgme_LIB_SRCS} )

   target_link_libraries( qgpgme ${QT_QTCORE_LIBRARY} ${_qgpgme_libgpgme} )

   set_target_properties( qgpgme PROPERTIES
     VERSION ${_qgpgme_version}
     SOVERSION ${_qgpgme_soversion}
   )

   install( TARGETS qgpgme EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})

   install( FILES
     qgpgme_export.h
     ${_qgpgme_extra_headers}
     dataprovider.h 
     DESTINATION ${INCLUDE_INSTALL_DIR}/qgpgme COMPONENT Devel )

endif ( _any_gpgme_found )
