cmake_minimum_required( VERSION 3.20 )

add_executable( fson-check FsonCheck.cpp )
target_link_libraries( fson-check fson cparse )

# fson-check ships with the runtime component so a host project (e.g. FFS)
# deploys the validator/converter next to the libraries it belongs to.
install( TARGETS fson-check
         RUNTIME
           COMPONENT   ${FSON_INSTALL_COMPONENT}
           DESTINATION ${CMAKE_INSTALL_BINDIR} )

# Shell completions travel with the tool. OPTIONAL so a stripped source tree
# still configures; installed where bash and zsh look by default.
set( _ac "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/auto-complete" )
install( FILES       "${_ac}/fson-check.bash"
         DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
         RENAME      "fson-check"
         COMPONENT   ${FSON_INSTALL_COMPONENT}
         OPTIONAL )
install( FILES       "${_ac}/_fson-check"
         DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions"
         COMPONENT   ${FSON_INSTALL_COMPONENT}
         OPTIONAL )
unset( _ac )
