From 00fda9b25aeb2522fc42e73b21dc615b97eee2e7 Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Sun, 31 Jan 2016 00:02:49 +0100 Subject: [PATCH] add a test for the find script on the build directory --- test/CMakeLists.txt | 9 +++++++++ test/find-package-test/CMakeLists.txt | 13 +++++++++++++ test/find-package-test/main.cpp | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 test/find-package-test/CMakeLists.txt create mode 100644 test/find-package-test/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 605a46a9..a3f134b1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -112,3 +112,12 @@ add_test(compile-test ${CMAKE_CTEST_COMMAND} "${CMAKE_CURRENT_BINARY_DIR}/compile-test" --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM}) + +# test if the targets are findable from the build directory +add_test(find-package-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/find-package-test" + "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options "-Dcppformat_DIR=${PROJECT_BINARY_DIR}") \ No newline at end of file diff --git a/test/find-package-test/CMakeLists.txt b/test/find-package-test/CMakeLists.txt new file mode 100644 index 00000000..ea6261e6 --- /dev/null +++ b/test/find-package-test/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(cppformat-test) + +find_package(cppformat REQUIRED) + +add_executable(library-test "main.cpp") +target_link_libraries(library-test cppformat) + +if (TARGET cppformat-header-only) + add_executable(header-only-test "main.cpp") + target_link_libraries(header-only-test cppformat-header-only) +endif () diff --git a/test/find-package-test/main.cpp b/test/find-package-test/main.cpp new file mode 100644 index 00000000..3563e606 --- /dev/null +++ b/test/find-package-test/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char** argv) +{ + for(int i = 0; i < argc; ++i) + fmt::print("{}: {}\n", i, argv[i]); + return 0; +}