diff --git a/CMakeLists.txt b/CMakeLists.txt index ca1c51b5cddb51ff4f42bc26fa85a66bcefd8999..efd84d0f23e966e942f758123cd3bc0cee297a8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ ENDIF() ########################################### message(STATUS "Build directory ${CMAKE_BINARY_DIR}") include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) # fix grpc - remove unsecure (no-op ssl implementations) string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC @@ -63,6 +63,8 @@ string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS "${CONAN_PKG_LIBS}") +message(STATUS "CONAN_LIBS: ${CONAN_LIBS}") + ########################################### ### GENERAL SETUP of SOURCES ########################################### @@ -145,17 +147,20 @@ add_custom_command( ############################################################################### if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") - add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) - add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) + add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) + add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) target_link_libraries(caosdb caosdb_grpc) + target_link_libraries(caosdb_grpc ${CONAN_LIBS}) set(LIBCAOSDB caosdb caosdb_grpc) + target_include_directories(caosdb_grpc SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} + ) target_include_directories(caosdb_grpc PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> - ${CONAN_INCLUDE_DIRS} ) else() add_library(caosdb @@ -165,11 +170,13 @@ endif() target_link_libraries(caosdb ${CONAN_LIBS} ) +target_include_directories(caosdb SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) target_include_directories(caosdb PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> - ${CONAN_INCLUDE_DIRS} ) add_library(ccaosdb SHARED src/ccaosdb.cpp) @@ -179,11 +186,13 @@ target_link_libraries(ccaosdb ) add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c) +target_include_directories(ccaosdbcli SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) target_include_directories(ccaosdbcli PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> - ${CONAN_INCLUDE_DIRS} ) target_link_libraries(ccaosdbcli ccaosdb @@ -191,11 +200,13 @@ target_link_libraries(ccaosdbcli ) add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp) +target_include_directories(cxxcaosdbcli SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) target_include_directories(cxxcaosdbcli PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> - ${CONAN_INCLUDE_DIRS} ) target_link_libraries(cxxcaosdbcli ${LIBCAOSDB} @@ -203,7 +214,6 @@ target_link_libraries(cxxcaosdbcli ) - ####################################################### ### LINTING with CLANG-TIDY and INCLUDE-WHAT-YOU-USE ####################################################### @@ -242,15 +252,15 @@ endfunction() option(LINTING "Enable linting with clang-tidy and iwyu when in non-Debug build-type" OFF) -if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" OR LINTING) +if (clang_tidy AND ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" OR LINTING)) set(_LINTING ON) endif() option(SKIP_LINTING "Skip linting even when in Debug build-type" OFF) -if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND SKIP_LINTING) +if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND SKIP_LINTING) message(WARNING "Skipping linting due to SKIP_LINTING option") set(_LINTING OFF) endif() -if(_LINTING) +if (_LINTING) ### set paranoid compiler flags add_compiler_flag("-Wall") diff --git a/Makefile b/Makefile index 367c0de989e9fa373b7a01afffc2720a5834508d..7eebeffcc9821e1961dd8ed2c6c9a509b2eb8cc5 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ else DETECTED_OS := $(patsubst MINGW%,MSYS,$(DETECTED_OS)) endif ifeq ($(DETECTED_OS),Darwin) # Test if we are on MacOS - CONAN_SETTINGS := "cppstd=11" + CONAN_SETTINGS := "compiler.cppstd=17" endif @@ -53,14 +53,27 @@ style: .PHONY: style conan-install: - conan install . -s $(CONAN_SETTINGS) || \ + conan install . -s $(CONAN_SETTINGS) || \ (echo "'conan install' failed, trying to build from sources..."; \ conan install . -s $(CONAN_SETTINGS) --build=missing) .PHONY: conan-install +conan-install-debug: + conan install . -s $(CONAN_SETTINGS) -s build_type=Debug || \ + (echo "'conan install' failed, trying to build from sources..."; \ + conan install . -s $(CONAN_SETTINGS) -s build_type=Debug --build=missing) +.PHONY: conan-install-debug + conan-create: conan create . -s $(CONAN_SETTINGS) .PHONY: conan-create +conan-create-debug: + conan create . -s $(CONAN_SETTINGS) -s build_type=Debug +.PHONY: conan-create-debug + conan: conan-install conan-create .PHONY: conan + +conan-debug: conan-install-debug conan-create-debug +.PHONY: conan-debug diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 27c6028d70eb608de54f879d4d6e4b59d070f2aa..8a26b4117b567dea4b5c3bb095964c2125ced813 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -136,6 +136,18 @@ include(CMakeParseArguments) option(CODE_COVERAGE_VERBOSE "Verbose information" FALSE) +option(SKIP_CODE_COVERAGE "Skip code coverage" OFF) + +if (SKIP_CODE_COVERAGE) + return() +endif() + +find_library(covlib NAMES gcov lcov) +message(STATUS "covlib: >${covlib}<") +if (${covlib} STREQUAL "covlib-NOTFOUND") + message(STATUS "lcov or gcov libraries not found, skipping code coverage.") + return() +endif() # Check prereqs find_program( GCOV_PATH gcov ) diff --git a/conanfile.py b/conanfile.py index 9c844fe71a6fe43d9e2eeffd4af17fbd14711aaa..895f8651c099ec9c6c4f861f9aa449d0a059a481 100644 --- a/conanfile.py +++ b/conanfile.py @@ -13,7 +13,11 @@ class CaosdbConan(ConanFile): options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} generators = "cmake" - requires = [("boost/1.76.0"), ("gtest/1.11.0"), ("grpc/1.38.0")] + requires = [ + ("boost/1.77.0"), + ("gtest/1.11.0"), + ("grpc/1.39.1"), + ] exports = "*.cpp", "*.h", "*.cmake", "*CMakeLists.txt", "*.in", "*.proto", "*.c" exports_sources = "src", "doc", "include", "test", "cmake", "proto" diff --git a/doc/README_SETUP.md b/doc/README_SETUP.md index 46026eee1da7ea078f93687812833f957bd75312..33a652c27e384b80db874655892aee8cc413d25d 100644 --- a/doc/README_SETUP.md +++ b/doc/README_SETUP.md @@ -6,7 +6,7 @@ ## Build -We use [cmake](https://cmake.org) as build tool. +We use [cmake](https://cmake.org) as build tool and assume gcc as compiler. 0. clone/update the subrepo `git submodule update --init proto` 1. `mkdir build && cd build` @@ -25,9 +25,9 @@ command (3.). ### How to build on MacOS -Instead of the above conan command (2.) use +If you use apple-clang as the compiler: Instead of the above conan command (2.) use -2. `conan install .. -s "cppstd=11"` +2. `conan install .. -s "compiler.cppstd=17"` and continue as you would when building on a Linux system. You may have to add `build/lib/` (or, alternatively after installation, @@ -37,7 +37,8 @@ variable. #### Problems and solutions #### - Make sure that your conan version supports your XCode version. A typical symptom of version - mismatch is for example conan complaining about incompatible `compiler.version` settings. + mismatch is for example conan complaining about incompatible `compiler.version` settings. You may + need to rerun any conan and cmake commands (and delete cache files first) after compiler updates. ### How to build on Windows @@ -73,6 +74,13 @@ dependencies. Depending on the clang version it might be necessary to use additionally the following flag: `-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"` +#### conan uses outdated cppstd during install + +If you experience compiler errors during a `conan install` process due +to, e.g., `std::string_view` being unavailable, try specifying the cpp +standard manually by `conan install .. [other options] -s +"compiler.cppstd=17"`. + ## Unit Tests ### Build @@ -80,12 +88,13 @@ Depending on the clang version it might be necessary to use additionally the fol For the tests there is a slightly different setup required (with option `-D CMAKE_BUILD_TYPE=Debug`) 1. `mkdir build && cd build/` -2. `conan install .. -s "compiler.libcxx=libstdc++11"` +2. `conan install .. ` (with gcc, append ` -s "compiler.libcxx=libstdc++11"`, with apple-clang, + append ` -s compiler.cppstd=17`) 3. `cmake -B . -D CMAKE_BUILD_TYPE=Debug ..` - * If your clang-format version is too old, formatting, linting etc. can be skipped: - `cmake -B . -D CMAKE_BUILD_TYPE=Debug -D SKIP_LINTING=ON ..` + * If your clang-format version is too old, formatting, linting etc. can be skipped: + `cmake -B . -D CMAKE_BUILD_TYPE=Debug -D SKIP_LINTING=ON ..` * Depending on the clang version it might be necessary to also add - `-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"` + `-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"` 5. `cmake --build .` ### Run