Skip to content
Snippets Groups Projects
Commit 2fdfea98 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-73-extern-adapt-to-conan-2-0' into 'dev'

Adapt for Conan 2

See merge request !35
parents 577dc4c9 ca7b280f
No related branches found
No related tags found
2 merge requests!41Release 0.3.0,!35Adapt for Conan 2
Pipeline #54976 passed
......@@ -5,9 +5,8 @@ COPY .docker/wait-for-it.sh /wait-for-it.sh
# build and install caosdb-cpplib
WORKDIR /libcaosdb/
RUN mkdir build
WORKDIR /libcaosdb/build
RUN conan create -s "compiler.libcxx=libstdc++11" -o caosdb:build_acm=True .. "caosdb/$(conan inspect --raw version ..)@_/_"
RUN conan profile detect -f
RUN make conan
COPY . /caosdb-cppinttest
WORKDIR /caosdb-cppinttest
......@@ -17,10 +16,7 @@ COPY .docker/caosdb-client.json /caosdb-client.json
# Build and run tests.
# If no other command is given to the Docker image
CMD mkdir build && \
cd build && \
conan install .. -s "compiler.libcxx=libstdc++11" && \
cmake .. && \
cmake --build . && \
CMD make build-release &&\
cd build/Release &&\
/wait-for-it.sh caosdb-server:10443 -t 500 -- \
ctest -V
......@@ -2,7 +2,6 @@
build/
include/libcaosdbConfig.h
cert/
.*
# CMake
CMakeLists.txt.user
......
......@@ -100,12 +100,8 @@ build-test:
tags: [ docker ]
stage: build
script:
- echo $PWD
- mkdir build
- cd build
- conan install .. -s "compiler.libcxx=libstdc++11"
- cmake ..
- cmake --build .
- echo $PWD
- make build-release
test:
......
......@@ -28,20 +28,16 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# dependency management with conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
# 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}")
# # fix grpc - remove unsecure (no-op ssl implementations)
# TODO: Find out if this is still necessary
# 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}")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
......
......@@ -35,14 +35,46 @@ CLANG_TIDY_CMD = $(CLANG_TIDY) \
.PHONY: help
help:
@echo "Targets:"
@echo " conan-install - Install locally with Conan."
@echo " conan-install-debug - Install locally with Conan."
@echo " conan-install-release - Install locally with Conan."
@echo " format - auto-format the source files."
@echo " build-debug - Build the project in Debug mode."
@echo " build-release - Build the project in Release mode."
@echo " test-debug - Run the tests in Debug mode."
@echo " test-release - Run the tests in Release mode."
@echo " clean - Remove build directories."
conan-install:
conan install . -s "compiler.libcxx=libstdc++11"
.PHONY: conan-install
conan-install-debug:
conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Debug --build=missing
conan-install-release:
conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Release --build=missing
format:
$(CLANG_FORMAT) -i --verbose \
$$(find test/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in")
.PHONY: format
build-debug: conan-install-debug
# cmake --preset conan-debug && cmake --build build/Debug # for CMake >= 3.23
cd build/Debug &&\
cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug &&\
cmake --build .
build-release: conan-install-release
# cmake --preset conan-release # for CMake >= 3.23
cd build/Release &&\
cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release &&\
cmake --build .
test-debug: build-debug
cd build/Debug && ctest
test-release: build-release
cd build/Release && ctest
clean:
rm -rf build
.PHONY: conan-install-debug conan-install-release build-debug build-release test-debug test-release
\ No newline at end of file
......@@ -12,13 +12,21 @@ Integration tests for caosdb-cpplib and the caosdb-server
# Run tests
## Prerequisite
## Prerequisites
Create a local conan package from the caosdb-cpplib repository
## Build & Execution
1. `mkdir build && cd build/`
2. `conan install .. -s "compiler.libcxx=libstdc++11"`
3. `cmake -B . ..`
```
make test-release
```
or manually via
1. `conan install . -s build_type=<Debug/Release> --build=missing`
2. `cmake --preset conan-<debug/release>`
3. `cd build <Debug/Release>`
4. `cmake --build .`
5. Provide client configuration at `~/.caosdb-client.json` or via any other method described in the docs.
6. There are tests which need access to the server's certificate file. Define
......
[requires]
caosdb/[>=0.3.0-dev, include_prerelease=True]
protobuf/3.21.12
grpc/1.48.4
[build_requires]
[test_requires]
gtest/1.11.0
[generators]
cmake
CMakeDeps
CMakeToolchain
[options]
caosdb:build_acm=True
caosdb*:build_acm=True
[layout]
cmake_layout
\ No newline at end of file
......@@ -86,10 +86,9 @@ if(LINTING)
else()
message(STATUS "clang-tidy: ${clang_tidy}")
set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}"
"--header-filter=caosdb/.*[^\(\.pb\.h\)]$"
"--fix")
"--header-filter=caosdb/.*[^\(\.pb\.h\)]$")
set(_CMAKE_CXX_CLANG_TIDY_CHECKS
"--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*")
"--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*,-misc-include-cleaner,-readability-identifier-length")
endif()
else()
message(STATUS "LINTING is OFF")
......@@ -103,22 +102,25 @@ endif()
# add special cmake functions for gtest
include(GoogleTest REQUIRED)
find_package(caosdb)
find_package(GTest)
find_package(gRPC)
find_package(protobuf)
# 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")
foreach (i RANGE "${len_test_cases}")
list(GET test_cases ${i} test_case_name)
add_executable(${test_case_name} ${test_case_name}.cpp)
target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB}
${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL}
${CONAN_LIBS_OPENSSL} ${CONAN_LIBS_C-ARES} ${CONAN_LIBS_BZIP2}
${CONAN_LIBS_PROTOBUF} ${CONAN_LIBS_ZLIB} ${CONAN_LIBS_RE2}
${CONAN_LIBS_BOOST})
target_link_libraries(${test_case_name} PRIVATE
caosdb::caosdb gtest::gtest grpc::grpc protobuf::protobuf
)
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
target_link_libraries(${test_case_name} PRIVATE caosdb_grpc)
endif()
target_include_directories(${test_case_name}
PUBLIC ${CONAN_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(LINTING)
set_target_properties(${test_case_name}
PROPERTIES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment