set(C_TOOLS
        athenawfisim
        attgen_dither
        comabackpro
        comadet
        comaexp
        comaimg
        comaimgPM
        comaphovign
        comarecon
        epicmos1_events
        epicmos2_events
        epicpn_events
        ero_calevents
        ero_exposure
        ero_fits2tm
        ero_rawevents
        ero_vis
        erosim
        evpat
        fudgexp
        gradeddetection
        htrssim
        imgev
        ladsim
        nustarsim
        orbatt
        pha2pi
        pixdetillum
        psfgen
        pulsetemplgen
        #pulsetemplimport
        radec2xy
        runmask
        runsixt
        runtes
        sixteversion
        streamtotriggers
        tes_grades
        tesconstpileup
        tesgenimpacts
        tesstream
        xifupipeline
        xms_pixtemp)

set(CPP_TOOLS
        exposure_map
        gendetsim
        piximpacts
        phogen
        phoimg
        projev
        makelc
        makespec
        sixte_arfgen
        sixtesim
	xml2svg
        )

# Tools which deviate from the usual folder structure
#set(EXTRA_TOOLS
#        sixte_arfgen
#        tessim)
#add_executable(sixte_arfgen sixte_arfgen/sixte_arfgen.cpp sixte_arfgen/region.c)
#add_executable(tessim tessim/tessim.c tessim/tessim_datastream.c
#        tessim/tessim_tesrecord.c tessim/tessim_impactlist.c
#        tessim/tes_simulation.c tessim/tessim_trigger.c tessim/tes_models.c
#        tessim/tessim_solvers.c tessim/tessim_bbfb.c)

set(TOOLS_WITHOUT_PARFILES sixteversion)


foreach(TOOL ${C_TOOLS})
    add_executable(${TOOL} "${TOOL}/${TOOL}.c")
endforeach()

foreach(TOOL ${CPP_TOOLS})
    add_executable(${TOOL} "${TOOL}/${TOOL}.cpp")
endforeach()

foreach(TOOL ${C_TOOLS};${CPP_TOOLS};${EXTRA_TOOLS})
    target_include_directories(${TOOL} PUBLIC
            ${EXT_INCLUDE_DIRS}
            ${SIMPUT_INCLUDE_DIR})
    target_link_directories(${TOOL} PUBLIC
            ${SIMPUT_LIBRARY_DIR})
    target_link_libraries(${TOOL} PUBLIC
            compiler_flags
            ${EXT_LIBRARIES}
            ${SIMPUT_LIBRARIES}
            libsixt
            libsixtcpp)

    install(TARGETS ${TOOL})
    if (NOT ${TOOL} IN_LIST TOOLS_WITHOUT_PARFILES)
      install(FILES ${TOOL}/${TOOL}.par DESTINATION share/sixte/pfiles)
    endif()

    # ### Apple Adjustments for missing boost headers ###
    # if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
    #     target_compile_definitions(${TOOL} PUBLIC unary_function=__unary_function)
    #     target_compile_definitions(${TOOL} PUBLIC binary_function=__binary_function)
    # endif ()
endforeach()
