include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${CMAKE_BINARY_DIR}
  ${TDE_INCLUDE_DIR}
)


##### install files

install(
  DIRECTORY include/ksquirrel-libs/
  DESTINATION ${INCLUDE_INSTALL_DIR}/ksquirrel-libs/
)


##### main ksquirrel-lib
file( GLOB _lib_cpp_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ksquirrel-libs/*.cpp )
tde_add_library( ksquirrel-libs SHARED AUTOMOC
  SOURCES ${_lib_cpp_files}
  VERSION 0.8.0
  DESTINATION ${LIB_INSTALL_DIR}
)


##### common codecs

function( conditional_build_codec _cond _codec )
  if( ${_cond} )
    file( GLOB _codec_cpp_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_codec}/*.cpp )
    tde_add_library( ${_codec} SHARED AUTOMOC
      SOURCES ${_codec_cpp_files}
      LINK ksquirrel-libs-shared
      VERSION 0.8.0
      DESTINATION ${LIB_INSTALL_DIR}/ksquirrel-libs
    )
  endif( )
endfunction( )

conditional_build_codec( BUILD_AVS    kls_avs    )
conditional_build_codec( BUILD_BMP    kls_bmp    )
conditional_build_codec( BUILD_CUT    kls_cut    )
conditional_build_codec( BUILD_DDS    kls_dds    )
conditional_build_codec( BUILD_FLI    kls_fli    )
conditional_build_codec( BUILD_HDR    kls_hdr    )
conditional_build_codec( BUILD_ICO    kls_ico    )
conditional_build_codec( BUILD_KOALA  kls_koala  )
conditional_build_codec( BUILD_LIF    kls_lif    )
conditional_build_codec( BUILD_MDL    kls_mdl    )
conditional_build_codec( BUILD_MTV    kls_mtv    )
conditional_build_codec( BUILD_PCX    kls_pcx    )
conditional_build_codec( BUILD_PIX    kls_pix    )
conditional_build_codec( BUILD_PNM    kls_pnm    )
conditional_build_codec( BUILD_PSD    kls_psd    )
conditional_build_codec( BUILD_PSP    kls_psp    )
conditional_build_codec( BUILD_PXR    kls_pxr    )
conditional_build_codec( BUILD_RAS    kls_ras    )
conditional_build_codec( BUILD_RAWRGB kls_rawrgb )
conditional_build_codec( BUILD_SCT    kls_sct    )
conditional_build_codec( BUILD_SGI    kls_sgi    )
conditional_build_codec( BUILD_SUN    kls_sun    )
conditional_build_codec( BUILD_TGA    kls_tga    )
conditional_build_codec( BUILD_WAL    kls_xbm    )
conditional_build_codec( BUILD_WBMP   kls_wbmp   )
conditional_build_codec( BUILD_XBM    kls_wal    )
conditional_build_codec( BUILD_XCUR   kls_xcur   )


# other codecs

if( BUILD_DICOM OR BUILD_PNG OR BUILD_SVG )
  add_subdirectory( ksquirrel-libs-png )
endif( )

tde_conditional_add_subdirectory( BUILD_CAMERA    kls_camera   )
tde_conditional_add_subdirectory( BUILD_DICOM     kls_dicom    )
tde_conditional_add_subdirectory( BUILD_DJVU      kls_djvu     )
tde_conditional_add_subdirectory( BUILD_DXF       kls_dxf      )
tde_conditional_add_subdirectory( BUILD_EPS       kls_eps      )
tde_conditional_add_subdirectory( BUILD_FIG       kls_fig      )
tde_conditional_add_subdirectory( BUILD_GIF       kls_gif      )
tde_conditional_add_subdirectory( BUILD_IFF       kls_iff      )
tde_conditional_add_subdirectory( BUILD_JBIG      kls_jbig     )
tde_conditional_add_subdirectory( BUILD_JPEG2000  kls_jpeg2000 )
tde_conditional_add_subdirectory( BUILD_JPEG      kls_jpeg     )
tde_conditional_add_subdirectory( BUILD_LEAF      kls_leaf     )
tde_conditional_add_subdirectory( BUILD_LJPEG     kls_ljpeg    )
tde_conditional_add_subdirectory( BUILD_MAC       kls_mac      )
tde_conditional_add_subdirectory( BUILD_MNG       kls_mng      )
tde_conditional_add_subdirectory( BUILD_MSP       kls_msp      )
tde_conditional_add_subdirectory( BUILD_NEO       kls_neo      )
tde_conditional_add_subdirectory( BUILD_OPENEXR   kls_openexr  )
tde_conditional_add_subdirectory( BUILD_PI1       kls_pi1      )
tde_conditional_add_subdirectory( BUILD_PI3       kls_pi3      )
tde_conditional_add_subdirectory( BUILD_PICT      kls_pict     )
tde_conditional_add_subdirectory( BUILD_PNG       kls_png      )
tde_conditional_add_subdirectory( BUILD_SVG       kls_svg      )
tde_conditional_add_subdirectory( BUILD_TIFF      kls_tiff     )
tde_conditional_add_subdirectory( BUILD_TTF       kls_ttf      )
tde_conditional_add_subdirectory( BUILD_UTAH      kls_utah     )
tde_conditional_add_subdirectory( BUILD_WMF       kls_wmf      )
tde_conditional_add_subdirectory( BUILD_XCF       kls_xcf      )
tde_conditional_add_subdirectory( BUILD_XIM       kls_xim      )
tde_conditional_add_subdirectory( BUILD_XPM       kls_xpm      )
tde_conditional_add_subdirectory( BUILD_XWD       kls_xwd      )

