set(C_TOOLS
        simputfile
        simputimg
        simputlc
        simputmerge
        simputmulticell
        simputmultispec
        simputpsd
        simputrotate
        simputspec
        simputsrc
        simputverify
        simputversion)


# Tools which deviate from the usual folder structure
# TODO add_subdirectory(galabs)
add_subdirectory(labnh)


set(TOOLS_WITHOUT_PARFILES simputversion)


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

foreach(TOOL ${C_TOOLS})
    target_include_directories(${TOOL} PUBLIC
            ${EXT_INCLUDE_DIRS})
    target_link_directories(${TOOL} PUBLIC
            ${EXT_LIBRARY_DIRS})
    target_link_libraries(${TOOL} PUBLIC
            compiler_flags
            ${EXT_LIBRARIES}
            simput)
    add_dependencies(${TOOL} wcslib_simput)

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