From 173f118b23aef2302dacf272420c5afde0413860 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 2 Jul 2021 10:42:00 +0200
Subject: [PATCH] WIP: conan

---
 test/CMakeLists.txt         | 10 ----------
 test/test_utils.cpp         |  1 +
 test_package/CMakeLists.txt | 14 ++++++++++++++
 test_package/conanfile.py   | 25 +++++++++++++++++++++++++
 test_package/example.cpp    |  8 ++++++++
 5 files changed, 48 insertions(+), 10 deletions(-)
 create mode 100644 test_package/CMakeLists.txt
 create mode 100644 test_package/conanfile.py
 create mode 100644 test_package/example.cpp

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a402a11..a088705 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -24,17 +24,9 @@ set(test_cases
     test_utils
     )
 
-# download gtest library
-#include(FetchGTest)
 # add special cmake functions for gtest
 include(GoogleTest)
 
-# disable linting for gtest targets (not our concern)
-#set_target_properties(gmock_main gmock gtest gtest_main PROPERTIES
-    #CXX_CLANG_TIDY ""
-    #CXX_INCLUDE_WHAT_YOU_USE ""
-    #EXCLUDE_FROM_ALL 1)
-
 # loop over all test cases and add them to the test runner
 list(LENGTH test_cases len_test_cases)
 math(EXPR len_test_cases "${len_test_cases} - 1")
@@ -48,8 +40,6 @@ foreach (i RANGE "${len_test_cases}")
             LABELS "caosdb-cpplib-unit-tests")
 endforeach ()
 
-
-
 # code coverage report
 include(CodeCoverage)
 
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index 619627c..245b0af 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -25,6 +25,7 @@
 #include <gtest/gtest-message.h>
 #include <gtest/gtest-test-part.h>
 #include "gtest/gtest_pred_impl.h"
+#include <boost/beast/core/detail/base64.hpp>
 
 TEST(test_utils, base64_encode) {
   auto test_plain = std::string("Test");
diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt
new file mode 100644
index 0000000..c575fe0
--- /dev/null
+++ b/test_package/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+project(PackageTest CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(example example.cpp)
+target_link_libraries(example ${CONAN_LIBS})
+
+# CTest is a testing tool that can be used to test your project.
+# enable_testing()
+# add_test(NAME example
+#          WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+#          COMMAND example)
diff --git a/test_package/conanfile.py b/test_package/conanfile.py
new file mode 100644
index 0000000..fb6117e
--- /dev/null
+++ b/test_package/conanfile.py
@@ -0,0 +1,25 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+
+class LibcaosdbTestConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        # Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
+        # in "test_package"
+        cmake.configure()
+        cmake.build()
+
+    def imports(self):
+        self.copy("*.dll", dst="bin", src="bin")
+        self.copy("*.dylib*", dst="bin", src="lib")
+        self.copy('*.so*', dst='bin', src='lib')
+
+    def test(self):
+        if not tools.cross_building(self):
+            os.chdir("bin")
+            self.run(".%sexample" % os.sep)
diff --git a/test_package/example.cpp b/test_package/example.cpp
new file mode 100644
index 0000000..9921648
--- /dev/null
+++ b/test_package/example.cpp
@@ -0,0 +1,8 @@
+#include <iostream>
+#include "caosdb/connection.h"
+
+int main() {
+  caosdb::connection::InsecureCaosDBConnectionConfig config("localhost", 8443);
+
+  std::cout << config << "\n";
+}
-- 
GitLab