################################################################################
# CLI - A simple command line interface.
# Copyright (C) 2016-2021 Daniele Pallastrelli
#
# Boost Software License - Version 1.0 - August 17th, 2003
#
# Permission is hereby granted, free of charge, to any person or organization
# obtaining a copy of the software and accompanying documentation covered by
# this license (the "Software") to use, reproduce, display, distribute,
# execute, and transmit the Software, and to prepare derivative works of the
# Software, and to permit third-parties to whom the Software is furnished to
# do so, all subject to the following:
#
# The copyright notices in the Software and this entire statement, including
# the above license grant, this restriction and the following disclaimer,
# must be included in all copies of the Software, in whole or in part, and
# all derivative works of the Software, unless such copies or derivative
# works are solely in the form of machine-executable object code generated by
# a source language processor.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
################################################################################

cmake_minimum_required(VERSION 3.8)
project(cli_test)
enable_testing()

set(Boost_ADDITIONAL_VERSIONS "1.66" "1.66.0")

set(Boost_NO_BOOST_CMAKE ON)
add_definitions( -DBOOST_ALL_NO_LIB ) # for windows

# finds boost, triggers an error otherwise
find_package(Boost 1.66 REQUIRED COMPONENTS unit_test_framework system)

# finds standalone asio, triggers an error otherwise
find_path(STANDALONE_ASIO_INCLUDE_PATH NAMES "asio.hpp" HINTS ${ASIO_INCLUDEDIR})
mark_as_advanced(STANDALONE_ASIO_INCLUDE_PATH)
add_library(standalone_asio_test INTERFACE)
target_include_directories(standalone_asio_test SYSTEM INTERFACE ${STANDALONE_ASIO_INCLUDE_PATH})
target_link_libraries(standalone_asio_test INTERFACE Threads::Threads)

# creates the executable
add_executable(
	test_suite
	driver.cpp
	test_history.cpp
	test_volatilehistorystorage.cpp
	test_filehistorystorage.cpp
	test_split.cpp
	test_commonprefix.cpp
	test_menu.cpp
	test_cli.cpp
	test_loopscheduler.cpp
	test_standaloneasioscheduler.cpp
	test_boostasioscheduler.cpp
)
# indicates the include paths
target_include_directories(test_suite SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
# indicates the shared library variant
target_compile_definitions(test_suite PRIVATE "BOOST_TEST_DYN_LINK=1")
# indicates the link paths
target_link_libraries(test_suite ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} Boost::system standalone_asio_test cli::cli)

# declares a test with our executable
add_test(NAME cli_test COMMAND test_suite)
