set(LIBSIXT_SOURCES
        advdet.c
        arcpixels.c
        attitude.c
        attitudefile.c
        background.c
        badpixmap.c
        balancing.c
        check_fov.c
        clocklist.c
        codedmask.c
        comadetector.c
        comaevent.c
        comaeventfile.c
        crosstalk.c
        det_phi_max.c
        detstruct2obj2d.c
        event.c
        eventarray.c
        eventfile.c
        eventlist.c
        fft_array.c
        find_position.c
        gendet.c
        gendetline.c
        genericdetector.c
        geninst.c
        genpixgrid.c
        gentel.c
        grading.c
        gti.c
        hexagonalpixels.c
        htrsdetector.c
        htrseventfile.c
        htrstelstream.c
        impact.c
        impactfile.c
        kdtreeelement.c
        lad.c
        lad_init.c
        ladevent.c
        ladeventfile.c
        ladimpact.c
        ladimpactfile.c
        ladsignal.c
        ladsignalfile.c
        ladsignallist.c
        linkedimplist.c
        linkedpholist.c
        maskshadow.c
        masksystem.c
        mt19937ar.c
        mxs.c
        namelist.c
        obj2d.c
        optimalfilters.c
        pha2pilib.c
        phabkg.c
        phdet.c
        phgen.c
        phimg.c
        photon.c
        photonfile.c
        phpat.c
        phproj.c
        pixelimpactfile.c
        pixeventfile.c
        projectedmask.c
        psf.c
        radec2xylib.c
        reconstruction.c
        repix.c
        rndgen.c
        sixt.c
        sixtesvg.c
        skyimage.c
        source.c
        sourcecatalog.c
        sourceimage.c
        squarepixels.c
        telemetrypacket.c
        tescrosstalk.c
        tesdatastream.c
        teseventlist.c
        tesinitialization.c
        tesnoisespectrum.c
        tesproftemplates.c
        tesrecord.c
        tesstreamfile.c
        testimg.c
        testrigger.c
        testriggerfile.c
        vignetting.c
        xmlbuffer.c)

set(LIBSIXT_HEADERS
        advdet.h
        arcpixels.h
        attitude.h
        attitudefile.h
        background.h
        badpixmap.h
        balancing.h
        check_fov.h
        clocklist.h
        codedmask.h
        comadetector.h
        comaevent.h
        comaeventfile.h
        crosstalk.h
        det_phi_max.h
        detstruct2obj2d.h
        event.h
        eventarray.h
        eventfile.h
        eventlist.h
        exponentialchargecloud.h
        fft_array.h
        find_position.h
        gaussianchargecloud.h
        gendet.h
        gendetline.h
        genericdetector.h
        geninst.h
        genpixgrid.h
        gentel.h
        grading.h
        gti.h
        hexagonalpixels.h
        htrsdetector.h
        htrsevent.h
        htrseventfile.h
        htrstelstream.h
        impact.h
        impactfile.h
        kdtreeelement.h
        lad.h
        ladevent.h
        ladeventfile.h
        ladimpact.h
        ladimpactfile.h
        ladsignal.h
        ladsignalfile.h
        ladsignallist.h
        linkedimplist.h
        linkedpholist.h
        maskshadow.h
        masksystem.h
        mt19937ar.h
        mxs.h
        namelist.h
        obj2d.h
        optimalfilters.h
        pha2pilib.h
        phabkg.h
        phdet.h
        phgen.h
        phimg.h
        photon.h
        photonfile.h
        phpat.h
        phproj.h
        pixelimpact.h
        pixelimpactfile.h
        point.h
        projectedmask.h
        psf.h
        radec2xylib.h
        reconstruction.h
        repix.h
        rndgen.h
        sixt.h
        sixtesvg.h
        skyimage.h
        source.h
        sourcecatalog.h
        sourceimage.h
        squarepixels.h
        telemetrypacket.h
        telescope.h
        tescrosstalk.h
        tesdatastream.h
        teseventlist.h
        tesinitialization.h
        tesnoisespectrum.h
        tespixel.h
        tesproftemplates.h
        tesreconstruction.h
        tesrecord.h
        tesstreamfile.h
        testimg.h
        testrigger.h
        testriggerfile.h
        vignetting.h
        xmlbuffer.h)

set(FITS_TEMPLATES
        coma.eventlist.tpl
        photonfile.tpl
        impactfile.tpl
        eventfile.tpl
        ladimpactfile.tpl
        ladsignalfile.tpl
        ladeventfile.tpl
        makespec.tpl
        makelc.tpl
        htrs.eventlist.tpl
        pixelimpactfile.tpl
        pixelimpactfile_gradingcols.tpl)

SET(LIB_NAME libsixt)

add_library(${LIB_NAME} SHARED ${LIBSIXT_SOURCES} ${LIBSIXT_HEADERS})
set_target_properties(${LIB_NAME} PROPERTIES VERSION "2.1.0")
target_include_directories(${LIB_NAME} PUBLIC
        ${PROJECT_BINARY_DIR} # for sixteconfig.h
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${EXT_INCLUDE_DIRS}
        ${SIMPUT_INCLUDE_DIR})
target_link_directories(${LIB_NAME} PUBLIC
        ${SIMPUT_LIBRARY_DIR})
target_link_libraries(${LIB_NAME} PUBLIC
        compiler_flags
        ${EXT_LIBRARIES}
        ${SIMPUT_LIBRARIES})
target_compile_definitions(${LIB_NAME} PUBLIC HTRS_ARCPIXELS)

# INSTALL
set(installable_libs ${LIB_NAME})
install(TARGETS ${installable_libs})
install(FILES ${LIBSIXT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${FITS_TEMPLATES} DESTINATION share/sixte/templates)
