#
# LDASTools diskcache - Tools for querying a collection of files on disk
#
# Copyright (C) 2018 California Institute of Technology
#
# LDASTools diskcache is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 (GPLv2) of the
# License or at your discretion, any later version.
#
# LDASTools diskcache is distributed in the hope that it will be useful, but
# without any warranty or even the implied warranty of merchantability
# or fitness for a particular purpose. See the GNU General Public
# License (GPLv2) for more details.
#
# Neither the names of the California Institute of Technology (Caltech),
# The Massachusetts Institute of Technology (M.I.T), The Laser
# Interferometer Gravitational-Wave Observatory (LIGO), nor the names
# of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# You should have received a copy of the licensing terms for this
# software included in the file LICENSE located in the top-level
# directory of this package. If you did not, you can view a copy at
# http://dcc.ligo.org/M1500244/LICENSE
#
#------------------------------------------------------------------------
# Standard compiler flags
#------------------------------------------------------------------------
#
#include $(LDAS_DIRECTORY_MAKE_INCLUDE)/compilerflags.mk
#
#RECURSIVE_TARGETS=$(PROJECT_RECURSIVE_TARGETS)
#
#comma = ,
#empty =
#space = $(empty) $(empty)
#tab = $(empty)	$(empty)
#
#libdiskcache_la = $(top_builddir)/src/libdiskcache.la
#

set( MKDIR_P_COMMAND ${CMAKE_COMMAND} -E make_directory )
set( RMDIR_COMMAND ${CMAKE_COMMAND} -E remove_directory )
set( TOUCH_COMMAND ${CMAKE_COMMAND} -E touch )
set( TEST_TIMEOUT 300 )

##------------------------------------------------------------------------
## Setup to use DejaGnu testing harness
##------------------------------------------------------------------------
#AUTOMAKE_OPTIONS=dejagnu
#RUNTESTDEFAULTFLAGS=--tool diskcacheAPI --srcdir=$(srcdir)/testsuite
#
##------------------------------------------------------------------------
## Variable definitions
##------------------------------------------------------------------------
#noinst_HEADERS =
#
#EXTRA_DIST = \
#	ldas-cache-dump-verify
#
#TESTS =
#TESTS += tSDGTx
#TESTS += test_diskcache_scan
#
#bin_PROGRAMS= 
#noinst_PROGRAMS =

set( bin_SCRIPTS
	ldas-cache-dump-verify
  )

#EXTRA_PROGRAMS=$(TESTS)
#
#TESTS_ENVIRONMENT=env LDAS_TOP=`pwd` $(TIME)
#
set( INCLUDES
  ${CMAKE_SOURCE_DIR}/src
  ${CMAKE_BINARY_DIR}/include
  ${CMAKE_BINARY_DIR}
  ${LDASTOOLS_INCLUDE_DIRS}
  )

set( LDADD
  diskcache
  ${LDASTOOLS_LIBRARIES_FULL_PATH}
  ${BOOST_FILESYSTEM_LIB}
  ${BOOST_REGEX_LIB}
  ${BOOST_SYSTEM_LIB}
  )

set( MOUNT_POINT_LIST_LDAS_OUTGOING
  ${CMAKE_BINARY_DIR}
  /ldas_outgoing/frames/RDSVerify
  /ldas_outgoing/jobs/output/rdsTest
  /ldas_outgoing/mirror/frames
  )
set( HAVE_MOUNT_POINT_LIST_LDAS_OUTGOING TRUE )
foreach( f ${MOUNT_POINT_LIST_LDAS_OUTGOING} )
  if ( NOT EXISTS ${f} )
    set( HAVE_MOUNT_POINT_LIST_LDAS_OUTGOING FALSE )
    break( )
  endif( )
endforeach( )

set( MOUNT_POINT_LIST_SCRATCH
  /scratch/test/system/ldas-dev
  /scratch/mirror/frames
  /scratch/test/frames
  /scratch/test/frames/subdir
  /scratch/test/system/ldas-dev
  )
set( HAVE_MOUNT_POINT_LIST_SCRATCH TRUE )
foreach( f ${MOUNT_POINT_LIST_SCRATCH} )
  if ( NOT EXISTS ${f} )
    set( HAVE_MOUNT_POINT_LIST_SCRATCH FALSE )
    break( )
  endif( )
endforeach( )

set( MOUNT_POINT_LIST_ARCHIVE
  /archive/frames/cache/S5
  /archive/frames/online
  /archive/frames/S1
  /archive/frames/S2
  /archive/frames/S3
  /archive/frames/S4
  /archive/frames/S5
  /archive/frames/S6
  /archive/frames/VSR1
  /archive/frames/VSR2
  /archive/frames/E1
  /archive/frames/E2
  /archive/frames/E3
  /archive/frames/E4
  /archive/frames/E5
  /archive/frames/E6
  /archive/frames/E7
  /archive/frames/E8
  /archive/frames/E9
  /archive/frames/E10
  /archive/frames/E11
  /archive/frames/E12
  /archive/frames/E13
  /archive/frames/E14
  /archive/frames/M1
  /archive/frames/M2
  /archive/frames/M3
  /archive/frames/M4
  /archive/frames/M5
  /archive/frames/M6
  /archive/frames/M7
  /archive/frames/M10
  /archive/frames/A0
  /archive/frames/A1
  /archive/frames/A2
  /archive/frames/A4
  /archive/frames/A5
  /archive/GEO/full/S1
  /archive/frames/ligovirgo
  /archive/frames/WSR8
  /archive/frames/trend/second-trend
  /archive/frames/trend/minute-trend
  /archive/frames/dmt
  /archive/frames/tmp
  )
if ( ENABLE_LONG_TESTS )
  set( HAVE_MOUNT_POINT_LIST_ARCHIVE TRUE )
  foreach( f ${MOUNT_POINT_LIST_ARCHIVE} )
    if ( NOT EXISTS ${f} )
      set( HAVE_MOUNT_POINT_LIST_ARCHIVE FALSE )
      break( )
    endif( )
  endforeach( )
endif( )

set( MOUNT_POINT_LIST_DISKCACHE
  ${MOUNT_POINT_LIST_LDAS_OUTGOING}
  ${MOUNT_POINT_LIST_SCRATCH}
  )
if ( HAVE_MOUNT_POINT_LIST_ARCHIVE )
  list( APPEND MOUNT_POINT_LIST_DISKCACHE ${MOUNT_POINT_LIST_ARCHIVE} )
endif( )
if ( ${HAVE_MOUNT_POINT_LIST_LDAS_OUTGOING}
    AND ${HAVE_MOUNT_POINT_LIST_SCRATCH}
    )
  set( HAVE_MOUNT_POINT_LIST_DISKCACHE TRUE )
else( )
  set( HAVE_MOUNT_POINT_LIST_DISKCACHE FALSE )
endif( )
string(REPLACE ";" "," MOUNT_POINT_LIST_DISKCACHE "${MOUNT_POINT_LIST_DISKCACHE}")
set( MOUNT_POINT_LIST_DISKCACHE_SMALL
  ${MOUNT_POINT_LIST_LDAS_OUTGOING}
  ${MOUNT_POINT_LIST_SCRATCH}
  )
if ( ${HAVE_MOUNT_POINT_LIST_LDAS_OUTGOING}
    AND ${HAVE_MOUNT_POINT_LIST_SCRATCH}
    )
  set( HAVE_MOUNT_POINT_LIST_DISKCACHE_SMALL TRUE )
else( )
  set( HAVE_MOUNT_POINT_LIST_DISKCACHE_SMALL FALSE )
endif( )
string(REPLACE ";" "," MOUNT_POINT_LIST_DISKCACHE_SMALL "${MOUNT_POINT_LIST_DISKCACHE_SMALL}")

#------------------------------------------------------------------------
# Target specific options
#------------------------------------------------------------------------
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# tSDGTx
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set( tSDGTx_SOURCES
  tSDGTx.cc
  )

cx_target_executable( tSDGTx_
  NOINST
  SOURCES ${tSDGTx_SOURCES}
  INCLUDE_DIRECTORIES BEFORE PRIVATE
    ${INCLUDES}
  LDADD ${LDADD}
  )

#cx_target_test( tSDGTx
#  COMMAND tSDGTx_
#  )


#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# tSDGTx
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set( test_diskcache_sub_commands_SOURCES
  test_diskcache_sub_commands.cc
  )

cx_target_executable( test_diskcache_sub_commands
  NOINST
  SOURCES ${test_diskcache_sub_commands_SOURCES}
  INCLUDE_DIRECTORIES BEFORE PRIVATE
  ${INCLUDES}
  LDADD ${LDADD}
  )

cx_target_test( test-diskcache-sub-commands
  COMMAND $<TARGET_FILE:test_diskcache_sub_commands>
)
set_tests_properties(
  test-diskcache-sub-commands
  PROPERTIES ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
## test_diskcache_scan_corner
##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#test_diskcache_scan_SOURCES = \
#	test_diskcache_scan_corner.cc
#
##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
## Generate directories with conflicting data
##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#.PHONY: conflicting-data-sets
add_custom_target( conflicting-data-sets
	COMMAND ${RMDIR_COMMAND} conflicting_data
  COMMAND ${MKDIR_P_COMMAND} conflicting_data/1_old_data
  COMMAND ${MKDIR_P_COMMAND} conflicting_data/2_new_data
  #---------------------------------------------------
  # ::::::::::::::::::::::: C1 :::::::::::::::::::::::
  #---------------------------------------------------
  # Conflict (new): [810000000,810000048:48)
  #     with (old): [810000016,810000032:16)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C1_A-810000016-16.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C1_A-810000000-48.gwf
  # Conflict (new): [810000016,810000032:16)
  #     with (old): [810000016,810000032:16)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C1_A-810000016-16.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C1_A-810000000-16.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C1_A-810000016-16.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C1_A-810000032-16.gwf
  #---------------------------------------------------
  # ::::::::::::::::::::::: C2 :::::::::::::::::::::::
  #---------------------------------------------------
  # Conflict (new): [820100016,820100032:16)
  #     with (old): [820100000,820100048:48)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_A-820100000-48.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C2_A-820100016-16.gwf
  # Conflict (new): [820101016,820101032:16)
  #     with (old): [820101000,820101048:24)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_A1-820101000-24.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_A1-820101024-24.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C2_A1-820101016-16.gwf
  # Conflict (new): [820200016,820200048:32)
  #     with (old): [820200000,820200048:48)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_B-820200000-48.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C2_B-820200016-32.gwf
  # Conflict (new): [820300000,820300032:32)
  #     with (old): [820300000,820300048:48)
  COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_C-820300000-48.gwf
  COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C2_C-820300000-32.gwf
  # Conflict (new): [820400000,820400048:48)
  #     with (old): [820400000,820400048:48)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C2_D-820400000-48.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C2_D-820400000-48.gwf
  #---------------------------------------------------
  # ::::::::::::::::::::::: C3 :::::::::::::::::::::::
  #---------------------------------------------------
  # Conflict (new): [830100015,830100045:30)
  #     with (old): [830100000,830100030:30)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C3_A-830100000-30.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C3_A-830100015-30.gwf
  # Conflict (new): [830100015,830100030:15)
  #     with (old): [830100000,830100030:30)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C3_A1-830101000-30.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C3_A1-830101015-15.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C3_A1-830101030-15.gwf
  # Conflict (new): [830200016,830200032:16)
  #     with (old): [830200000,830200048:48)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C3_B-830200000-15.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C3_B-830200000-30.gwf
  #---------------------------------------------------
  # ::::::::::::::::::::::: C4 :::::::::::::::::::::::
  #---------------------------------------------------
  #define BOOST_TEST_MAIN
  #include <boost/test/included/unit_test.hpp>

  # Conflict (new): [840100000,840100032:32)
  #     with (old): [840100016,840100048:32)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C4_A-840100016-32.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_A-840100000-32.gwf
  # Conflict (new): [840101014,840101028:14)
  #     with (old): [840101016,840101048:32)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C4_A1-840101016-32.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_A1-840101000-14.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_A1-840101014-14.gwf
  # Conflict (new): [840200000,840200032:32)
  #     with (old): [840200016,840200032:16)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C4_B-840200016-16.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_B-840200000-32.gwf
  # Conflict (new): [840202010,840202030:10)
  #     with (old): [840202015,840202030:15)
	COMMAND ${TOUCH_COMMAND} conflicting_data/1_old_data/Z-C4_B1-840201015-15.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_B1-840201000-10.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_B1-840201010-10.gwf
	COMMAND ${TOUCH_COMMAND} conflicting_data/2_new_data/Z-C4_B1-840201020-10.gwf
)


##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
## Generate directories with varing discovery orders
##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

add_custom_target( ordering-data-sets
  COMMAND ${RMDIR_COMMAND} ordering_data
  COMMAND ${MKDIR_P_COMMAND} ordering_data/data
  # In order
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-InOrder-810000010-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-InOrder-810000020-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-InOrder-810000030-10.gwf
  # Reverse order
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-ReverseOrder-810000030-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-ReverseOrder-810000020-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-ReverseOrder-810000010-10.gwf
  # Fill gap
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-FillGap-810000010-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-FillGap-810000030-10.gwf
  COMMAND ${TOUCH_COMMAND} ordering_data/data/Z-FillGap-810000020-10.gwf
)

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Generate directories which test corner cases
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

add_custom_target( corner-data-sets
  COMMAND ${RMDIR_COMMAND} corner_data
  COMMAND ${MKDIR_P_COMMAND} corner_data/data
  COMMAND ${TOUCH_COMMAND} corner_data/data/H-H1_RDS_R_L1-935866240-64.gwf
  COMMAND ${TOUCH_COMMAND} corner_data/data/H-H1_RDS_R_L1-935866304-64.gwf
  COMMAND ${TOUCH_COMMAND} corner_data/data/H-H1_RDS_R_L1-935866368-32.gwf
  COMMAND ${TOUCH_COMMAND} corner_data/data/H-H1_RDS_R_L1-935866528-32.gwf
 )

##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
## local tests
##::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

cx_target_test( diskcache-scan-conflicts
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  	--mount-points ${CMAKE_CURRENT_BINARY_DIR}/conflicting_data
	  --extensions .gwf
	  --concurrency 1
  DEPENDS diskcache_exe conflicting-data-sets
)

set_tests_properties( diskcache-scan-conflicts
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

cx_target_test( diskcache-scan-corner
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  --mount-points ${CMAKE_CURRENT_BINARY_DIR}/corner_data
	--extensions .gwf
	--concurrency 1
	--output-ascii -
  DEPENDS diskcache_exe corner-data-sets
)

set_tests_properties( diskcache-scan-corner
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

cx_target_test( diskcache-scan-ordering
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  --mount-points ${CMAKE_CURRENT_BINARY_DIR}/ordering_data
	--extensions .gwf
	--concurrency 1
  DEPENDS diskcache_exe ordering-data-sets
)

set_tests_properties( diskcache-scan-ordering
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

cx_target_test( diskcache-scan-full-5
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  --mount-points ${MOUNT_POINT_LIST_DISKCACHE}
	--extensions .gwf
	--concurrency 5
  DEPENDS diskcache_exe
)

set_tests_properties( diskcache-scan-full-5
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

configure_file(
  diskcache-scan-full-5.cfg.in
  diskcache-scan-full-5.cfg
  @ONLY
  )
cx_target_test( diskcache-scan-full-5-cfg
  COMMAND $<TARGET_FILE:diskcache_exe>
  --log-directory ${CMAKE_CURRENT_BINARY_DIR}/logs/diskcache_scan_full_5_cfg/
  --log-archive-directory ${CMAKE_CURRENT_BINARY_DIR}/logs/diskcache_scan_full_5_cfg/
  --log diskcache-scan-full-5-cfg
  --log-debug-level 0
  scan
  --configuration-file diskcache-scan-full-5.cfg
  DEPENDS diskcache_exe
  )

  set_tests_properties( diskcache-scan-full-5-cfg
    PROPERTIES
    RUN_SERIAL TRUE
    TIMEOUT ${TEST_TIMEOUT}
    ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
  )

cx_target_test( diskcache-scan-full-5-cfg-override
  COMMAND $<TARGET_FILE:diskcache_exe>
  --log-directory ${CMAKE_CURRENT_BINARY_DIR}/diskcache-scan-full-5-cfg-override.d/
  --log-archive-directory ${CMAKE_CURRENT_BINARY_DIR}/diskcache-scan-full-5-cfg-override.d/
  --log diskcache-scan-full-5-cfg-override
  --log-debug-level 0
  --log-format text
  scan
  --configuration-file diskcache-scan-full-5.cfg
  --output-ascii diskcache-scan-full-5-cfg-override.txt
  DEPENDS diskcache_exe
  )

  set_tests_properties( diskcache-scan-full-5-cfg-override
    PROPERTIES
    RUN_SERIAL TRUE
    TIMEOUT ${TEST_TIMEOUT}
    ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
  )

cx_target_test( diskcache-scan-full-100
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  --mount-points ${MOUNT_POINT_LIST_DISKCACHE}
	--extensions .gwf
	--concurrency 100
  DEPENDS diskcache_exe
)

set_tests_properties( diskcache-scan-full-100
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

cx_target_test( diskcache-scan-small-5
  COMMAND $<TARGET_FILE:diskcache_exe> scan
  --mount-points ${MOUNT_POINT_LIST_DISKCACHE_SMALL}
	--extensions .gwf
	--concurrency 5
  DEPENDS diskcache_exe
)

set_tests_properties( diskcache-scan-small-5
  PROPERTIES
  RUN_SERIAL TRUE
  TIMEOUT ${TEST_TIMEOUT}
  ENVIRONMENT "ASAN_OPTIONS=$ENV{ASAN_OPTIONS}"
)

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

cx_scheme_sanitizer_set_environment( )
#
#.PHONY: diskcache-scan-scratch-memcheck
#diskcache-scan-scratch-memcheck: diskcache
#	$(MAKE) COMMAND_OPTIONS="scan \
#	--mount-points $(MOUNT_POINT_LIST_SCRATCH) \
#	--extensions .gwf \
#	--concurrency 5" \
#	VALGRIND_TESTS=diskcache memcheck

install(
  PROGRAMS ${bin_SCRIPTS}
  DESTINATION ${CMAKE_INSTALL_BINDIR}
  )
