diff --git a/.docker/Dockerfile b/.docker/Dockerfile index df8ef0a9f18f5754eae33686e832bd88f37da9de..320a6e21ee770a360d0f71ccb8a1cc7cf74e7ca0 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -7,7 +7,8 @@ RUN apt-get install -y doxygen graphviz RUN apt-get install -y clang-format-11 clang-tidy-11 RUN apt-get install -y python3-pip RUN apt-get install -y git -RUN apt-get install -y curl +RUN apt-get install -y curl zip unzip tar + RUN apt-get install -y openjdk-11-jdk-headless diff --git a/.gitignore b/.gitignore index 7ddf9b7e3c77a0cc492c738c47b5a97a6b7e7997..109a1c662e332aa16dee2de295fb1fd0dd116207 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,6 @@ conanbuildinfo.cmake conanbuildinfo.txt conaninfo.txt graph_info.json + +# vcpkg +vcpkg_installed \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3bea0c5f3a4bf2371811b6fc8c50f0e3f4ca83fd..49cf623cbf03c38b73ad01b15d09427b4bd9694f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -81,6 +81,17 @@ code_style: - clang-format-11 --dry-run --verbose --Werror $(find test/ src/ include/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") allow_failure: true + +# build with vcpkg +build_vcpkg: + tags: [ docker ] + stage: test + script: + - apt update && apt install -y pkg-config + - cd vcpkg && git fetch origin 5d3798ac7388ca66c169773e46103b14077b76a4 && cd .. + - make vcpkg-build-release + allow_failure: true + # unit tests with gtest test: tags: [ docker ] diff --git a/.gitmodules b/.gitmodules index 80d822f671b09d8a0eaf0e4bbb4104ae6c587905..f937552d4b116474da1258942473e4dc95edd12c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "proto"] path = proto url = ../caosdb-proto.git +[submodule "vcpkg"] + path = vcpkg + url = https://github.com/microsoft/vcpkg diff --git a/CMakeLists.txt b/CMakeLists.txt index eb566f0d90c7e6d3819b5130356117a5815d56cd..f6de5cf9d1950fa09fe5457a569bb021c42587c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,9 @@ # This file is a part of the CaosDB Project. # # Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> -# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2021 Joscha Schmiedt <joscha@schmiedt.dev> +# Copyright (C) 2021-2024 IndiScale GmbH <info@indiscale.com> +# # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -51,24 +53,8 @@ IF (BUILD_ACM) add_compile_definitions("BUILD_ACM") ENDIF() -########################################### -### DEPENDENCY MANAGEMENT with CONAN -########################################### message(STATUS "Build directory ${CMAKE_BINARY_DIR}") -# TODO: Is this still necessary? -# # fix grpc - remove unsecure (no-op ssl implementations) -# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC -# "${CONAN_LIBS_GRPC}") -# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC -# "${CONAN_PKG_LIBS_GRPC}") -# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS -# "${CONAN_LIBS}") -# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS -# "${CONAN_PKG_LIBS}") - -# message(STATUS "CONAN_LIBS: ${CONAN_LIBS}") - ########################################### ### GENERAL SETUP of SOURCES ########################################### @@ -81,7 +67,7 @@ add_subdirectory(doc) ### CODE GENERATION (WITH GRPC) #################################################################### -# TODO: Replace this with the protobuf_generate_cpp function +find_package(protobuf CONFIG REQUIRED) # Protobuf/Grpc source files set(PROTO_FILES @@ -97,12 +83,11 @@ ENDIF() set(PROTO_PATH ${PROJECT_SOURCE_DIR}/proto/proto) +set(_PROTOBUF_PROTOC ${Protobuf_PROTOC_EXECUTABLE}) # compiler binaries IF (WIN32) - set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc.exe") set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin.exe") ELSE() - set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc") set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin") ENDIF() @@ -162,8 +147,11 @@ message(DEBUG "GRPC_GENERATED: ${GRPC_GENERATED}") ############################################################################### find_package(gRPC CONFIG REQUIRED) -find_package(Protobuf CONFIG REQUIRED) -find_package(Boost 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) find_package(GTest REQUIRED) # print include directories for debugging @@ -180,7 +168,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) target_link_libraries(caosdb_grpc - grpc::grpc protobuf::protobuf boost::boost + gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES} ) target_include_directories(caosdb_grpc PUBLIC $<BUILD_INTERFACE:${PROJECT_INCLUDE_DIR}> @@ -191,7 +179,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) target_link_libraries(caosdb - caosdb_grpc grpc::grpc protobuf::protobuf boost::boost + caosdb_grpc gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES} ) set(LIBCAOSDB caosdb caosdb_grpc) @@ -199,7 +187,7 @@ else() add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) target_link_libraries(caosdb - grpc::grpc protobuf::protobuf boost::boost + gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES} stdc++fs ) set(LIBCAOSDB caosdb) @@ -220,7 +208,7 @@ target_include_directories(caosdb PUBLIC # ---------- add_library(ccaosdb SHARED src/ccaosdb.cpp) target_link_libraries(ccaosdb - grpc::grpc protobuf::protobuf boost::boost + gRPC::grpc gRPC::grpc++ protobuf::libprotobuf ${Boost_LIBRARIES} ${LIBCAOSDB} stdc++fs ) @@ -244,7 +232,7 @@ target_include_directories(ccaosdbcli SYSTEM PUBLIC ) target_link_libraries(ccaosdbcli - grpc::grpc protobuf::protobuf boost::boost + gRPC::grpc protobuf::libprotobuf ${Boost_LIBRARIES} ${LIBCAOSDB} ccaosdb ) @@ -262,7 +250,7 @@ target_include_directories(cxxcaosdbcli SYSTEM PUBLIC ) target_link_libraries(cxxcaosdbcli ${LIBCAOSDB} - grpc::grpc protobuf::protobuf boost::boost + gRPC::grpc protobuf::libprotobuf ${Boost_LIBRARIES} ) diff --git a/Makefile b/Makefile index 682257ad63ca86f0c776b372e36d5c3e108fd9e1..43e792af8a27ecf982ea1dbb0768c3bc38d5f9d6 100644 --- a/Makefile +++ b/Makefile @@ -97,6 +97,17 @@ conan-build-debug: conan build . -s $(CONAN_SETTINGS) -s build_type=Debug +vcpkg-install: + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics\ + &&vcpkg/vcpkg install + +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 --build . + ctest: cd build/Debug && ctest diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 32f54a4e3afa5efdf9f3afb49c40d1221f183267..82af15fb394963c75cea5215c648977a88b9afbd 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Connection::ListUsers method +- Connection::ListUsers method +- Added support for compilation with vcpkg. ### Changed diff --git a/doc/Install_develop.rst b/doc/Install_develop.rst index 67618dc45457e87a1d0fb15b509b97cb4eca8ce2..38d55b8a5d199da83394ae21b9b603b943f7d4fb 100644 --- a/doc/Install_develop.rst +++ b/doc/Install_develop.rst @@ -9,8 +9,8 @@ Dependencies Build ----- -Building with ``make`` -~~~~~~~~~~~~~~~~~~~~~~ +Building with ``make`` and Conan +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Make sure that the dependencies (see above) are fulfilled. On systems which have ``make`` installed, type this in your command line terminal: @@ -19,8 +19,8 @@ which have ``make`` installed, type this in your command line terminal: make conan -Manual build -~~~~~~~~~~~~ +Manual build with Conan +~~~~~~~~~~~~~~~~~~~~~~~ We use `cmake <https://cmake.org>`__ as build tool, with Conan as package manager. The compiler must support the C++17 standard. @@ -28,7 +28,7 @@ package manager. The compiler must support the C++17 standard. 1. clone/update the subrepo ``git submodule update --init proto`` 2. ``conan install . -s build_type=Release --build=missing`` 3. ``cd build/Release`` -4. ``cmake .`` +4. ``cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release`` 5. ``cmake --build .`` You may also want to install libcaosdb system-wide to @@ -51,6 +51,43 @@ If you want to build or install libcaosdb without the use of Conan, feel free to rewrite the CMakeLists.txt as needed. The CaosDB project is open to merge requests which support multiple ways of installation. +Optional: Building with ``vcpkg`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Next to Conan, you also have the option to use the vcpkg package manager to install the +dependencies (`vcpkg.json`). Note, however, *vcpkg is not fully supported and tested*. It's +included as a submodule in the project. To install the dependencies, run the following +commands: + +.. code:: console + + ./vcpkg/bootstrap-vcpkg.<sh/bat> -disableMetrics + vcpkg/vcpkg install + + +Copy the ``grpc-cpp-plugin`` to the build directory (TODO: This should ideally be done automatically by CMake): + +.. code:: console + + mkdir -p build/build_tools + cp vcpkg_installed/<os>/tools/grpc/grpc_cpp_plugin build/build_tools + +Then compile the project with CMake by including the vcpkg toolchain file: + +.. code:: console + + cd build + cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_BUILD_TYPE=Release + cmake --build . + +Alternatively, on Linux, you can use the provided `Makefile` targets + +.. code:: console + + make vcpkg-build-release + + + How to build on MacOS ~~~~~~~~~~~~~~~~~~~~~ @@ -74,7 +111,7 @@ as compiler. We use `cmake <https://cmake.org/download/>`__ as build tool. 1. clone/update the subrepo ``git submodule update --init proto`` -2. ``conan install .. -g visual_studio -s arch=x86_64 -s build_type=Release -s compiler.toolset=v142 -s compiler.version=16 -s compiler.runtime=MD --build=missing --update`` +2. :code:``conan install .. -g visual_studio -s arch=x86_64 -s build_type=Release -s compiler.toolset=v142 -s compiler.version=16 -s compiler.runtime=MD --build=missing --update`` 3. ``cd build/Release`` 5. ``cmake -B . ..`` 6. open ``libcaosdb.sln`` with Visual Studio, change the buildtype to diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp index e1ffb23b3b1a2db5ecea79588c237bb36e79b1e1..deddcd423ffc4c73158b63fb7cc9f89a6beb8a4d 100644 --- a/src/caosdb/configuration.cpp +++ b/src/caosdb/configuration.cpp @@ -343,7 +343,7 @@ auto CreateLoggingConfiguration(const object &from) -> LoggingConfiguration { const auto *elem = sinks.begin(); while (elem != sinks.end()) { - result.AddSink(CreateSinkConfiguration(elem->value().as_object(), elem->key().to_string(), + result.AddSink(CreateSinkConfiguration(elem->value().as_object(), std::string(elem->key()), default_level)); elem = std::next(elem); } @@ -419,7 +419,7 @@ auto ConfigurationManager::mGetDefaultConnectionName() const -> std::string { } if (connections.size() == 1) { // return the key of the first and only sub-element of connections. - return connections.begin()->key().to_string(); + return std::string(connections.begin()->key()); } throw ConfigurationError("Could not determine the default connection."); } diff --git a/vcpkg b/vcpkg new file mode 160000 index 0000000000000000000000000000000000000000..333ba63a16024f05f9172fe403f9eced000389e5 --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit 333ba63a16024f05f9172fe403f9eced000389e5 diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000000000000000000000000000000000..07d24d3af78c26e6d4078b5bb5fedcd59b50522d --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,20 @@ +{ + "name": "caosdb", + "version-string": "0.3.0-dev", + "port-version": 1, + "description": "C++ library for the CaosDB project", + "license": "AGPL-3.0-or-later", + "dependencies": [ + "boost-beast", + "boost-filesystem", + "boost-json", + "boost-log", + "boost-smart-ptr", + "boost-thread", + "grpc", + "protobuf", + "zlib", + "gtest" + ], + "builtin-baseline": "5d3798ac7388ca66c169773e46103b14077b76a4" +}