#------------------------------------------------------------------------
# -*- mode: cmake -*-
#------------------------------------------------------------------------
if (COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif (COMMAND CMAKE_POLICY)
#------------------------------------------------------------------------
# global variables
#------------------------------------------------------------------------

#------------------------------------------------------------------------
# Find some pieces that will be needed
#------------------------------------------------------------------------

include_directories(BEFORE
  ${CMAKE_SOURCE_DIR}/src/client
)
include_directories(BEFORE
  ${CMAKE_BINARY_DIR}/src/client
)

add_definitions( "-DHAVE_CONFIG_H=1" )

#------------------------------------------------------------------------
#
#------------------------------------------------------------------------

#------------------------------------------------------------------------
# Generate the system configuration file
#------------------------------------------------------------------------

#========================================================================
# Utilities
#========================================================================
# Binary utilities
#------------------------------------------------------------------------
add_executable(
  nds_query
  daq_test.c
)
target_link_libraries(
  nds_query
  ndsclient
  ${CMAKE_DL_LIBS}
)
#------------------------------------------------------------------------
add_executable(
  nds2_channel_source
  nds2_channel_source.c
)
target_link_libraries(
  nds2_channel_source
  ndsclient
  ${CMAKE_DL_LIBS}
)
#------------------------------------------------------------------------
# Scripts - bourne
#------------------------------------------------------------------------
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/nds-client-config.in
                ${CMAKE_CURRENT_BINARY_DIR}/nds-client-config
		@ONLY
)
set( sh_scripts ${sh_scripts} ${CMAKE_CURRENT_BINARY_DIR}/nds-client-config )
set( sh_scripts ${sh_scripts} nds2-tunnel )
#========================================================================
# Installation Rules
#========================================================================
install(
  TARGETS
    nds_query
    nds2_channel_source
  RUNTIME
  DESTINATION ${CMAKE_INSTALL_BINDIR}
  COMPONENT applications
)
if( NOT WIN32)
  install(
    PROGRAMS ${sh_scripts}
    DESTINATION ${CMAKE_INSTALL_BINDIR}
    PERMISSIONS
        OWNER_READ OWNER_WRITE OWNER_EXECUTE
        GROUP_READ GROUP_EXECUTE
        WORLD_READ WORLD_EXECUTE
    COMPONENT applications
  )
endif( NOT WIN32 )
