From 6da08cdafa9c14ceec2908884dd000da02da240a Mon Sep 17 00:00:00 2001
From: Joscha Schmiedt <joscha@schmiedt.dev>
Date: Wed, 18 Sep 2024 22:06:31 +0200
Subject: [PATCH] Minor fixes for vcpkg

- Fix GTest spelling in test/CMakeLists.txt
- Restrict vcpkg triplet to release
- Add set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- Include of <gtest/gtest.h> in tests instead of smaller headers
- Add boost options to CMakeLists.txt
---
 CMakeLists.txt                  | 23 +++++++++++++++++------
 Makefile                        |  2 +-
 test/CMakeLists.txt             |  4 ++--
 test/test_clinkahead.cpp        |  4 +---
 test/test_configuration.cpp     |  1 +
 test/test_connection.cpp        |  1 +
 test/test_data_type.cpp         |  2 +-
 test/test_entity.cpp            |  1 +
 test/test_file_transmission.cpp |  4 +---
 test/test_info.cpp              |  3 +--
 test/test_issues.cpp            |  4 +---
 test/test_list_properties.cpp   |  4 +---
 test/test_protobuf.cpp          |  6 ++----
 test/test_transaction.cpp       |  6 ++----
 test/test_utility.cpp           |  6 ++----
 test/test_value.cpp             |  4 +---
 16 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a77ba68..7556d30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ project(liblinkahead
 
 set(CMAKE_C_STANDARD 11)
 set(CMAKE_CXX_STANDARD 17)
-
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 set(CMAKE_C_EXTENSIONS OFF)
 set(CMAKE_C_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_EXTENSIONS OFF)
@@ -145,11 +145,22 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
 ###############################################################################
 
 find_package(gRPC CONFIG REQUIRED)
-find_package(Boost COMPONENTS json REQUIRED)
-find_package(Boost COMPONENTS filesystem REQUIRED)
-find_package(Boost COMPONENTS log REQUIRED)
-find_package(Boost COMPONENTS thread REQUIRED)
-find_package(Boost COMPONENTS system REQUIRED)
+
+# boost
+find_package(Boost REQUIRED COMPONENTS json filesystem log thread system log_setup)
+# find_package(Boost REQUIRED COMPONENTS filesystem )
+# find_package(Boost REQUIRED COMPONENTS log )
+# find_package(Boost REQUIRED COMPONENTS thread )
+# find_package(Boost REQUIRED COMPONENTS system )
+
+# Boost settings
+set(Boost_USE_STATIC_LIBS        ON)  # only find static libs
+set(Boost_USE_DEBUG_LIBS        OFF)  # ignore debug libs and
+set(Boost_USE_RELEASE_LIBS       ON)  # only find release libs
+set(Boost_USE_MULTITHREADED      ON)
+set(Boost_USE_STATIC_RUNTIME     ON)  # link Boost Static libraries
+
+
 find_package(GTest REQUIRED)
 
 # print include directories for debugging
diff --git a/Makefile b/Makefile
index 368cb1b..d807cfa 100644
--- a/Makefile
+++ b/Makefile
@@ -117,7 +117,7 @@ vcpkg-build-release: vcpkg-install
 	mkdir -p build/build_tools\
 	  && cp vcpkg_installed/x64-linux/tools/grpc/grpc_cpp_plugin build/build_tools\
 	  && cd build\
-	  && cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_BUILD_TYPE=Release\
+	  && cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux-release -DCMAKE_BUILD_TYPE=Release\
       && cmake --build .
 .PHONY: vcpkg-build-release
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6497de6..7b70f9f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -51,7 +51,7 @@ set(_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS
 )
 
 # add special cmake functions for gtest
-find_package(GTest REQUIRED)
+find_package(GTest CONFIG REQUIRED)
 include(GoogleTest)
 
 message(DEBUG "CMAKE_INCLUDE_PATH: ${CMAKE_INCLUDE_PATH}")
@@ -65,7 +65,7 @@ foreach (i RANGE "${len_test_cases}")
     set(liblinkahead_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp
         ${liblinkahead_TEST_SRC}")
     target_link_libraries(${test_case_name}
-        PRIVATE GTest::gtest_main linkahead clinkahead gtest::gtest caosdb_grpc)
+        PRIVATE GTest::gtest_main linkahead clinkahead GTest::gtest caosdb_grpc ${Boost_LIBRARIES})
     target_include_directories(${test_case_name}
       PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})     
      set_target_properties(${test_case_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY  "${CMAKE_BINARY_DIR}")
diff --git a/test/test_clinkahead.cpp b/test/test_clinkahead.cpp
index 0cd8afb..a46f41e 100644
--- a/test/test_clinkahead.cpp
+++ b/test/test_clinkahead.cpp
@@ -20,9 +20,7 @@
  *
  */
 
-#include <gtest/gtest-message.h>     // for Message
-#include <gtest/gtest-test-part.h>   // for TestPartResult
-#include <gtest/gtest_pred_impl.h>   // for AssertionResult, EXPECT_EQ, EXP...
+#include <gtest/gtest.h>
 #include <cstdint>                   // for int64_t
 #include <cstring>                   // for strcmp
 #include <filesystem>                // for path
diff --git a/test/test_configuration.cpp b/test/test_configuration.cpp
index 18c1028..b2cc95f 100644
--- a/test/test_configuration.cpp
+++ b/test/test_configuration.cpp
@@ -19,6 +19,7 @@
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  *
  */
+#include <gtest/gtest.h>             // for Test, TestPartResult, TestPartR...
 #include <gtest/gtest-message.h>     // for Message
 #include <gtest/gtest-test-part.h>   // for TestPartResult
 #include <gtest/gtest_pred_impl.h>   // for TestInfo, TEST_F, Test
diff --git a/test/test_connection.cpp b/test/test_connection.cpp
index 07db64a..2b92e94 100644
--- a/test/test_connection.cpp
+++ b/test/test_connection.cpp
@@ -22,6 +22,7 @@
 #ifdef BUILD_ACM
 #include "linkahead/acm/user.h" // for User
 #endif
+#include <gtest/gtest.h>                    // for Test, TestPartResult, Test
 #include <gtest/gtest-message.h>            // for Message
 #include <gtest/gtest-test-part.h>          // for TestPartResult
 #include <gtest/gtest_pred_impl.h>          // for AssertionResult, TestInfo
diff --git a/test/test_data_type.cpp b/test/test_data_type.cpp
index 08799d4..272f373 100644
--- a/test/test_data_type.cpp
+++ b/test/test_data_type.cpp
@@ -19,7 +19,7 @@
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  *
  */
-
+#include <gtest/gtest.h>               // for TEST, EXPECT_EQ, EXPECT_FALSE, ...
 #include <gtest/gtest-message.h>       // for Message
 #include <gtest/gtest-test-part.h>     // for TestPartResult
 #include <gtest/gtest_pred_impl.h>     // for AssertionResult, Test, EXPECT_EQ
diff --git a/test/test_entity.cpp b/test/test_entity.cpp
index 3eab1a7..6c5c4a7 100644
--- a/test/test_entity.cpp
+++ b/test/test_entity.cpp
@@ -21,6 +21,7 @@
  *
  */
 #include <google/protobuf/arena.h>         // for Arena
+#include <gtest/gtest.h>                   // for Test, TestPartResult, Test
 #include <gtest/gtest-message.h>           // for Message
 #include <gtest/gtest-test-part.h>         // for TestPartResult
 #include <gtest/gtest_pred_impl.h>         // for Test, EXPECT_EQ, Assertio...
diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp
index ce51735..1291731 100644
--- a/test/test_file_transmission.cpp
+++ b/test/test_file_transmission.cpp
@@ -17,9 +17,7 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
-#include <gtest/gtest-message.h>                     // for Message
-#include <gtest/gtest-test-part.h>                   // for TestPartResult
-#include <gtest/gtest_pred_impl.h>                   // for AssertionResult
+#include <gtest/gtest.h>
 #include <filesystem>                                // for path, exists
 #include <string>                                    // for basic_string
 #include "linkahead/file_transmission/file_reader.h" // for FileReader
diff --git a/test/test_info.cpp b/test/test_info.cpp
index 2e77754..fc6fd3a 100644
--- a/test/test_info.cpp
+++ b/test/test_info.cpp
@@ -20,8 +20,7 @@
  *
  */
 
-#include <gtest/gtest-message.h>    // for Message
-#include <gtest/gtest-test-part.h>  // for TestPartResult
+#include <gtest/gtest.h>
 #include "caosdb/info/v1/main.pb.h" // for VersionInfo
 #include "gtest/gtest_pred_impl.h"  // for Test, EXPECT_EQ, TestInfo, TEST
 #include "linkahead/info.h"         // for VersionInfo
diff --git a/test/test_issues.cpp b/test/test_issues.cpp
index 594eded..25b1a87 100644
--- a/test/test_issues.cpp
+++ b/test/test_issues.cpp
@@ -17,9 +17,7 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
-#include <gtest/gtest-message.h>          // for Message
-#include <gtest/gtest-test-part.h>        // for TestPartResult
-#include <gtest/gtest_pred_impl.h>        // for Test, EXPECT_EQ, TestInfo
+#include <gtest/gtest.h>
 #include <memory>                         // for unique_ptr
 #include <string>                         // for basic_string
 #include "linkahead/configuration.h"      // for InsecureConnectionConfigur...
diff --git a/test/test_list_properties.cpp b/test/test_list_properties.cpp
index ec9c8f2..8c8dfe2 100644
--- a/test/test_list_properties.cpp
+++ b/test/test_list_properties.cpp
@@ -20,9 +20,7 @@
  *
  */
 
-#include <gtest/gtest-message.h>      // for Message
-#include <gtest/gtest-test-part.h>    // for TestPartResult
-#include <gtest/gtest_pred_impl.h>    // for AssertionResult, Test, EXPECT_...
+#include <gtest/gtest.h>
 #include <cstdint>                    // for int64_t
 #include <string>                     // for basic_string, string
 #include <vector>                     // for vector
diff --git a/test/test_protobuf.cpp b/test/test_protobuf.cpp
index ab489cc..a49c205 100644
--- a/test/test_protobuf.cpp
+++ b/test/test_protobuf.cpp
@@ -19,10 +19,8 @@
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  *
  */
-#include <google/protobuf/arena.h>    // for Arena
-#include <gtest/gtest-message.h>      // for Message
-#include <gtest/gtest-test-part.h>    // for TestPartResult
-#include <gtest/gtest_pred_impl.h>    // for EXPECT_EQ, Test, TestInfo, TEST
+#include <google/protobuf/arena.h> // for Arena
+#include <gtest/gtest.h>
 #include "caosdb/entity/v1/main.pb.h" // for Entity, Message, Version, Data...
 #include "linkahead/data_type.h"      // for DataType, ReferenceDataType
 #include "linkahead/entity.h"         // for Entity
diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp
index e41bced..cb936c0 100644
--- a/test/test_transaction.cpp
+++ b/test/test_transaction.cpp
@@ -17,10 +17,8 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
-#include <google/protobuf/arena.h>        // for Arena
-#include <gtest/gtest-message.h>          // for Message
-#include <gtest/gtest-test-part.h>        // for TestPartResult
-#include <gtest/gtest_pred_impl.h>        // for Test, EXPECT_EQ, TestInfo
+#include <google/protobuf/arena.h> // for Arena
+#include <gtest/gtest.h>
 #include <filesystem>                     // for path
 #include <memory>                         // for unique_ptr, make_unique
 #include <stdexcept>                      // for out_of_range
diff --git a/test/test_utility.cpp b/test/test_utility.cpp
index c86da80..9880d1e 100644
--- a/test/test_utility.cpp
+++ b/test/test_utility.cpp
@@ -20,14 +20,12 @@
  *
  */
 
-#include <gtest/gtest-message.h>              // for Message
-#include <gtest/gtest-test-part.h>            // for TestPartResult
-#include <gtest/gtest_pred_impl.h>            // for Test, EXPECT_EQ, TestInfo
+#include <gtest/gtest.h>
 #include <map>                                // for _Rb_tree_const_iterator
 #include <stdexcept>                          // for out_of_range
 #include <string>                             // for basic_string, string
 #include <utility>                            // for pair
-#include "boost/beast/core/detail/base64.hpp" // for encoded_size
+#include <boost/beast/core/detail/base64.hpp> // for encoded_size
 #include "linkahead/data_type.h"              // for AtomicDataType, atomic...
 #include "linkahead/entity.h"                 // for Importance, Role, impo...
 #include "linkahead/status_code.h"            // for get_status_description
diff --git a/test/test_value.cpp b/test/test_value.cpp
index b2770e5..0dab4d6 100644
--- a/test/test_value.cpp
+++ b/test/test_value.cpp
@@ -20,9 +20,7 @@
  *
  */
 
-#include <gtest/gtest-message.h>       // for Message
-#include <gtest/gtest-test-part.h>     // for TestPartResult
-#include <gtest/gtest_pred_impl.h>     // for AssertionResult, Test, EXPECT...
+#include <gtest/gtest.h>
 #include <cmath>                       // for sqrt, isnan
 #include <initializer_list>            // for initializer_list
 #include <string>                      // for basic_string, string, operator+
-- 
GitLab