Skip to content
Snippets Groups Projects
Verified Commit e7d4db2f authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'main' into f-conan2

parents 81ef5224 68e93791
No related branches found
No related tags found
No related merge requests found
Pipeline #9637 canceled
......@@ -15,6 +15,8 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
*ConfigVersion.cmake
# C
## Prerequisites
......
......@@ -127,7 +127,6 @@ trigger_inttest:
script:
- mkdir -p build
- cd build
- conan install ..
- cmake ..
- cmake --build . --target doc-sphinx
- cp -r doc/sphinx_out ../public
......@@ -139,7 +138,7 @@ pages:
<<: *pages_prepare
only:
refs:
- /^release-.*$/i
- main
artifacts:
paths:
- public
......@@ -20,7 +20,7 @@
cmake_minimum_required(VERSION 3.14)
set(libcaosdb_VERSION 0.0.1)
set(libcaosdb_VERSION 0.0.2)
project(libcaosdb
VERSION ${libcaosdb_VERSION}
......@@ -36,11 +36,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# dependency management with conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
#conan_basic_setup()
set(PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
option(LINTING ON)
if(LINTING)
find_program(iwyu NAMES include-what-you-use iwyu PATHS ${CMAKE_SOURCE_DIR}/tools/include-what-you-use/${iwyu_os}/bin)
if(NOT iwyu)
message(STATUS "include-what-you-use: Not found")
......@@ -59,6 +61,9 @@ else()
"--checks=*,-fuchsia-*,-llvm-include-order,-llvmlibc-*"
"--warnings-as-errors=*")
endif()
else()
message(STATUS "LINTING is OFF")
endif()
add_subdirectory(src)
add_subdirectory(include)
......@@ -244,5 +249,12 @@ install(FILES ${GRPC_GENERATED_HEADERS}
install(FILES ${PROJECT_SOURCE_DIR}/caosdbConfig.cmake
DESTINATION ${libcaosdb_CMAKE_DEST})
#set_property(TARGET caosdb PROPERTY VERSION ${libcaosdb_VERSION})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_SOURCE_DIR}/caosdbConfigVersion.cmake"
VERSION ${libcaosdb_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES ${PROJECT_SOURCE_DIR}/caosdbConfigVersion.cmake
DESTINATION ${libcaosdb_CMAKE_DEST})
......@@ -4,15 +4,85 @@
We use [cmake](https://cmake.org) as build tool.
1. `cmake -B build`
2. `cd build`
1. `mkdir build && cd build/`
2. `cmake -B . ..`
3. `cmake --build .`
### Troubleshooting
#### protobufConfig.cmake not found
If you encounter something like `protobufConfig.cmake not found` when doing
`cmake -B . ..` your system doesn't have the gRPC library installed at all
or your installation doesn't have the required `protobufConfig.cmake`
file. In this case you can install grpcc manually by cloning the
repository and its submodules nad building it from the sources:
```sh
RUN git clone --recurse-submodules -b v1.38.1 https://github.com/grpc/grpc
cd grpc
mkdir -p cmake/build
cp cmake/build
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_CSHARP_EXT=OFF \
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
-DgRPC_BUILD_TESTS=OFF \
../..
make -j3 # Or whatever number of jobs suits your system
make install
```
It may make sense to specify a custom directory for your grpc
installation such as `$HOME/.local` by adding
`-DCMAKE_INSTALL_PREFIX=/path/to/install/dir` to the above `cmake`
command. This prevents interference with a possible system-wide
installation of grpc that's lacking the relevant cmake files.
Depending on your system, it may be necessary to manually install the
`abseil` submodule:
```sh
cd grpc
mkdir -p third_party/abseil-cpp/cmake/build
cd third_party/abseil-cpp/cmake/build
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
make -j3
make install
```
As above, it may make sense to specify a `CMAKE_INSTALL_PREFIX` in
order to not interfere with system-wide installations.
You may have to repeat this for other submodules that haven't been
installed correctly by `make install` of `grpc`.
## Unit Tests
### Build
For the tests there is a slightly different setup required (with option `-D CMAKE_BUILD_TYPE=Debug`)
1. `mkdir build && cd build/`
2. `cmake -B . -D CMAKE_BUILD_TYPE=Debug ..`
3. `cmake --build .`
### Run
Build tests as described above. In the build directory, run `ctest`
In the build directory, run `ctest`
### Troubleshooting
Depending on your gtest installation, there may be warnings treated as
errors during the above build command, e.g., a
`-Werror=maybe-uninitialized` in
`caosdb-cpplib-new/build/_deps/googletest-src/googletest/src/gtest-death-test.cc`. In
that case, suppress the corresponding warning by adding
`-DCMAKE_CXX_FLAGS="-Wno-maybe-uninitialized"` to the cmake command in 2.
### Framework
......@@ -35,7 +105,8 @@ The coverage report can be viewed in a browser by opening
## Code Formatting
* `clang-format -i --verbose **/*.cpp **/*.h`
* install clang-format on your system.
* `clang-format -i --verbose $(find test/ src/ include/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in")`
## Documentation
......
......@@ -43,12 +43,12 @@ if (DOXYGEN_FOUND)
foreach (i RANGE "${len_header_files}")
list(GET libcaosdb_INCL ${i} HEADER_FILE)
string(REPLACE
"${PROJECT_INCLUDE_DIR}/"
"${PROJECT_INCLUDE_DIR}/caosdb/"
""
HEADER_FILE_NAME
${HEADER_FILE})
string(REPLACE
"${CMAKE_BINARY_DIR}/include/"
"${CMAKE_BINARY_DIR}/include/caosdb/"
""
HEADER_FILE_NAME
${HEADER_FILE_NAME})
......
......@@ -26,7 +26,9 @@
#include <fstream>
#include <string>
#include <cstdlib>
/*
#include <boost/beast/core/detail/base64.hpp>
*/
namespace caosdb::utils {
......@@ -68,14 +70,16 @@ inline auto get_env_var(const std::string &key, const std::string &fall_back)
* @brief Encode string as base64
*/
inline auto base64_encode(const std::string &plain) -> std::string {
auto size_plain = plain.size();
auto size_encoded = boost::beast::detail::base64::encoded_size(size_plain);
return std::string("YWRtaW46Y2Fvc2Ri");
// TODO
// auto size_plain = plain.size();
// auto size_encoded = boost::beast::detail::base64::encoded_size(size_plain);
char encoded[size_encoded];
boost::beast::detail::base64::encode(&encoded, plain.c_str(), size_plain);
// char encoded[size_encoded];
// boost::beast::detail::base64::encode(&encoded, plain.c_str(), size_plain);
// the encoded char[] is not null terminated, so explicitely set the length
return std::string(encoded, encoded + size_encoded);
//// the encoded char[] is not null terminated, so explicitely set the length
// return std::string(encoded, encoded + size_encoded);
}
} // namespace caosdb::utils
......
......@@ -42,7 +42,7 @@ auto main() -> int {
const auto host =
caosdb::utils::get_env_var("CAOSDB_SERVER_HOST", "localhost");
const auto port_str =
caosdb::utils::get_env_var("CAOSDB_SERVER_PORT", "8000");
caosdb::utils::get_env_var("CAOSDB_SERVER_PORT", "8443");
const auto port = std::stoi(port_str);
const auto user = caosdb::utils::get_env_var("CAOSDB_USER", "admin");
const auto password = caosdb::utils::get_env_var("CAOSDB_PASSWORD", "caosdb");
......
......@@ -21,7 +21,7 @@
# append all the test cases here (file name without the ".cpp" suffix)
set(test_cases
test_connection
test_utils
#test_utils
)
# download gtest library
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment