From e0477637ebcb68e229ee5935635143a87f24cc57 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 16 Dec 2021 03:45:24 +0200 Subject: [PATCH] Add test/cmake_install_test --- test/cmake_install_test/CMakeLists.txt | 17 +++++++++++++++++ test/cmake_install_test/main.cpp | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/cmake_install_test/CMakeLists.txt create mode 100644 test/cmake_install_test/main.cpp diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 0000000..c317bba --- /dev/null +++ b/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_install_test LANGUAGES CXX) + +find_package(boost_function REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::function) + +enable_testing() +add_test(main main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_install_test/main.cpp b/test/cmake_install_test/main.cpp new file mode 100644 index 0000000..3435a94 --- /dev/null +++ b/test/cmake_install_test/main.cpp @@ -0,0 +1,22 @@ +// Copyright 2017, 2021 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/function + +#include +#include + +#define BOOST_TEST(expr) assert(expr) +#define BOOST_TEST_EQ(x1, x2) assert((x1)==(x2)) + +int add( int x, int y ) +{ + return x + y; +} + +int main() +{ + boost::function fn( &add ); + BOOST_TEST_EQ( fn( 1, 2 ), 3 ); +}