set(TOOL_NAME dsviewer)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

find_package(PkgConfig)
pkg_search_module(EDITLINE REQUIRED libeditline)
include_directories(${EDITLINE_INCLUDE_DIRS})
link_directories(${EDITLINE_LIBRARY_DIRS})

aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})

set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)

target_link_libraries(${TOOL_NAME} PRIVATE gctl)
target_link_libraries(${TOOL_NAME} PRIVATE ${EDITLINE_LIBRARIES})

install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION sbin)

file(GLOB HELP_DOC *.md)
install(FILES ${HELP_DOC} DESTINATION sbin/share)
