diff --git a/.clang-format b/.clang-format index bd28a67..0ac8ee0 100644 --- a/.clang-format +++ b/.clang-format @@ -17,4 +17,4 @@ IncludeCategories: Priority: 3 SortPriority: 0 -ColumnLimit: 120 \ No newline at end of file +ColumnLimit: 120 diff --git a/.github/actions/build-package-cmake/action.yml b/.github/actions/build-package-cmake/action.yml new file mode 100644 index 0000000..0a306a3 --- /dev/null +++ b/.github/actions/build-package-cmake/action.yml @@ -0,0 +1,50 @@ +name: "build-package-cmake" +description: "Install package and build example" +inputs: + build_tests: + default: "false" + install: + default: "true" + description: "Install the package after build" +runs: + using: "composite" + steps: + - name: Detect OS and install OpenSSL + shell: bash + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + choco install openssl -y + openssl version + fi + + - name: Detect OS and set std::chrono flag + shell: bash + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + echo "USE_CHRONO=OFF" >> $GITHUB_ENV + elif [[ "${{ runner.os }}" == "Windows" ]]; then + echo "USE_CHRONO=ON" >> $GITHUB_ENV + fi + - name: Cmake configuration without tests + if: ${{inputs.build_tests == 'false'}} + shell: bash + run: cmake -S . -B build -DREDUCT_CPP_USE_STD_CHRONO=$USE_CHRONO + + - name: Cmake configuration with tests + if: ${{inputs.build_tests == 'true'}} + shell: bash + run: cmake -S . -B build -DREDUCT_CPP_ENABLE_TESTS=ON -DREDUCT_CPP_USE_STD_CHRONO=$USE_CHRONO + + - name: Build package + shell: bash + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + cmake --build build + elif [[ "${{ runner.os }}" == "Windows" ]]; then + cmake --build build --config Release + fi + + - name: Install package + if: ${{inputs.install == 'true' }} + run: sudo cmake --install build + shell: bash diff --git a/.github/actions/build-package/action.yml b/.github/actions/build-package/action.yml index 4ec0733..76e259f 100644 --- a/.github/actions/build-package/action.yml +++ b/.github/actions/build-package/action.yml @@ -1,24 +1,49 @@ name: "build-package" description: "Install package and build example" inputs: + build_tests: + default: "false" install: default: "true" description: "Install the package after build" runs: using: "composite" steps: + - uses: ./.github/actions/install-conan + + - name: Run conan install + shell: bash + run: conan install . --build=missing -s:a=compiler.cppstd=20 + + - name: Detect OS and set preset name + shell: bash + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + echo "PRESET=conan-release" >> $GITHUB_ENV + elif [[ "${{ runner.os }}" == "Windows" ]]; then + echo "PRESET=conan-default" >> $GITHUB_ENV + fi + + - name: Cmake configuration without tests + if: ${{inputs.build_tests == 'false'}} + shell: bash + run: cmake --preset $PRESET + + - name: Cmake configuration with tests + if: ${{inputs.build_tests == 'true'}} + shell: bash + run: cmake --preset $PRESET -DREDUCT_CPP_ENABLE_TESTS=ON + - name: Build package shell: bash - run: cmake -DCMAKE_BUILD_TYPE=Debug -DREDUCT_CPP_ENABLE_EXAMPLES=ON -DREDUCT_CPP_ENABLE_TESTS=ON -S . -B build + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + cmake --build --preset $PRESET + elif [[ "${{ runner.os }}" == "Windows" ]]; then + cmake --build build --config Release + fi + - name: Install package if: ${{inputs.install == 'true' }} + run: sudo cmake --install build/Release shell: bash - run: sudo cmake --build build --target install - - name: Build example - if: ${{inputs.install == 'true' }} - shell: bash - run: | - mkdir examples/build - cd examples/build - cmake .. - cmake --build . diff --git a/.github/actions/install-conan/action.yml b/.github/actions/install-conan/action.yml new file mode 100644 index 0000000..0bb6875 --- /dev/null +++ b/.github/actions/install-conan/action.yml @@ -0,0 +1,12 @@ +name: "install-conan" + +runs: + using: "composite" + steps: + - name: Install conan + shell: bash + run: pip3 install conan==2.11.0 + + - name: Create profile + shell: bash + run: conan profile detect diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index e02180a..aa83eb6 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -2,19 +2,19 @@ name: "run-tests" description: "Pull storage and run tests" inputs: api-token: # id of input - description: 'API_TOKEN' + description: "API_TOKEN" required: false default: "" tags: # id of input - description: 'Tags for tests' + description: "Tags for tests" required: false default: "" reductstore-version: # id of input - description: 'Reduct Store version' + description: "Reduct Store version" required: false default: "main" lic_file: # id of input - description: 'License file' + description: "License file" required: true runs: using: "composite" @@ -33,4 +33,4 @@ runs: docker logs reduct-store - name: Run tests shell: bash - run: REDUCT_CPP_TOKEN_API=${{inputs.api-token}} build/bin/reduct-tests ${{inputs.tags}} + run: REDUCT_CPP_TOKEN_API=${{inputs.api-token}} build/Release/bin/reduct-tests ${{inputs.tags}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d50575..efda656 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,11 @@ name: ci on: push: - branches: [ main ] + branches: [main] tags: - - 'v*' + - "v*" pull_request: - branches: [ main ] + branches: [main] jobs: cpplint: runs-on: ubuntu-latest @@ -26,8 +26,8 @@ jobs: needs: cpplint strategy: matrix: - build_type: [ "cmake", "conan" ] - os: [ ubuntu-22.04, windows-2019 ] + build_type: ["cmake", "conan"] + os: [ubuntu-22.04, windows-2019] include: - os: ubuntu-22.04 install: "true" @@ -35,19 +35,26 @@ jobs: install: "false" steps: - uses: actions/checkout@v4 - - name: Install conan + with: + fetch-depth: 0 + - name: Build without conan + if: ${{ matrix.build_type == 'cmake' }} + uses: ./.github/actions/build-package-cmake + with: + install: ${{ matrix.install }} + + - name: Build with conan if: ${{ matrix.build_type == 'conan' }} - run: pip3 install conan==1.64.1 - - uses: ./.github/actions/build-package + uses: ./.github/actions/build-package with: install: ${{ matrix.install }} unit-tests: strategy: matrix: - token: [ "", "TOKEN" ] - reductstore_version: [ "main", "latest" ] - license_file: [ "", "lic.key" ] + token: ["", "TOKEN"] + reductstore_version: ["main", "latest"] + license_file: ["", "lic.key"] include: - token: "" exclude_token_api_tag: "~[token_api]" @@ -65,7 +72,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: ./.github/actions/build-package + with: + build_tests: true - name: Generate license run: echo '${{secrets.LICENSE_KEY}}' > lic.key diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d2141b..73ec846 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,34 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-added-large-files + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.17.1 + hooks: + - id: gersemi + + - repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile", "black", "--filter-files"] -- repo: local + - repo: local hooks: - - id: cpplint - name: cpplint - description: Static code analysis of C/C++ files - language: python - files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ - entry: cpplint + - id: cpplint + name: cpplint + description: Static code analysis of C/C++ files + language: python + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + entry: cpplint diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a8090..4930901 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - RS-550: Add when condition to replication settings, [PR-80](https://github.com/reductstore/reduct-cpp/pull/80) +### Changed + +- RS-563: Support for Conan v2, [PR-83](https://github.com/reductstore/reduct-cpp/pull/83) + ## [1.13.0] - 2024-12-04 ### Added @@ -150,7 +154,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- `Bucket.list`, [PR-42](https://github.com/reduct-storage/reduct-cpp/pull/42) +- `Bucket.list`, [PR-42](https://github.com/reduct-storage/reduct-cpp/pull/42) ### Changed @@ -231,51 +235,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial implementation of Reduct Storage API v0.1.0 [Unreleased]: https://github.com/reduct-storage/reduct-cpp/compare/v1.13.0...HEAD - [1.13.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.12.0...1.13.0 - [1.12.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.11.0...1.12.0 - [1.11.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.10.0...1.11.0 - [1.10.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.9.0...1.10.0 - [1.9.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.8.0...1.9.0 - [1.8.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.7.1...1.8.0 - [1.7.1]: https://github.com/reduct-storage/reduct-cpp/compare/v1.7.0...1.7.1 - [1.7.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.6.0...1.7.0 - [1.6.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.5.0...1.6.0 - [1.5.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.4.0...1.5.0 - [1.4.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.3.0...1.4.0 - [1.3.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.2.0...1.3.0 - [1.2.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.1.0...1.2.0 - [1.1.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.0.1...1.1.0 - [1.0.1]: https://github.com/reduct-storage/reduct-cpp/compare/v1.0.0...1.0.1 - [1.0.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.8.0...1.0.0 - [0.8.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.7.0...v0.8.0 - [0.7.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.6.0...v0.7.0 - [0.6.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.5.0...v0.6.0 - [0.5.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.4.0...v0.5.0 - [0.4.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.3.0...v0.4.0 - [0.3.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.2.0...v0.3.0 - [0.2.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.1.0...v0.2.0 - [0.1.0]: https://github.com/reduct-storage/reduct-cpp/releases/tag/v0.1.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index f345bf1..dd5d72f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,11 @@ project(reductcpp VERSION ${REDUCT_CPP_FULL_VERSION}) message(STATUS "Version ${REDUCT_CPP_FULL_VERSION}") set(REDUCT_CPP_ENABLE_TESTS OFF CACHE BOOL "Compile tests") -set(REDUCT_CPP_USE_STD_CHRONO OFF CACHE BOOL "use std::chrono instead of date library") +set(REDUCT_CPP_USE_STD_CHRONO + OFF + CACHE BOOL + "use std::chrono instead of date library" +) set(CMAKE_CXX_STANDARD 20) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -18,10 +22,18 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) include(cmake/InstallDependencies.cmake) -configure_file(cmake/ReductCppConfig.cmake.in ${CMAKE_BINARY_DIR}/cmake/ReductCppConfig.cmake @ONLY) -configure_file(cmake/ReductCppConfigVersion.cmake.in ${CMAKE_BINARY_DIR}/cmake/ReductCppConfigVersion.cmake @ONLY) +configure_file( + cmake/ReductCppConfig.cmake.in + ${CMAKE_BINARY_DIR}/cmake/ReductCppConfig.cmake + @ONLY +) +configure_file( + cmake/ReductCppConfigVersion.cmake.in + ${CMAKE_BINARY_DIR}/cmake/ReductCppConfigVersion.cmake + @ONLY +) add_subdirectory(src) -if (REDUCT_CPP_ENABLE_TESTS) +if(REDUCT_CPP_ENABLE_TESTS) add_subdirectory(tests) -endif () +endif() diff --git a/CPPLINT.cfg b/CPPLINT.cfg index cfd14a7..03b4425 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,2 +1,2 @@ filter=-build/c++11,-build/header_guard,-build/include -linelength=120 \ No newline at end of file +linelength=120 diff --git a/cmake/InstallDependencies.cmake b/cmake/InstallDependencies.cmake index 820dc80..5c83517 100644 --- a/cmake/InstallDependencies.cmake +++ b/cmake/InstallDependencies.cmake @@ -1,64 +1,70 @@ -if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") - message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") - file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake" - "${CMAKE_BINARY_DIR}/conan.cmake" - EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484 - TLS_VERIFY ON) -endif () - -include(${CMAKE_BINARY_DIR}/conan.cmake) - find_program(CONAN_CMD conan) -if (CONAN_CMD) - conan_cmake_autodetect(settings) - conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_CURRENT_SOURCE_DIR}/conanfile.py - BUILD missing - SETTINGS ${settings}) - - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() +if(CONAN_CMD) + find_package(fmt REQUIRED) + find_package(nlohmann_json REQUIRED) + find_package(httplib REQUIRED) + find_package(concurrentqueue REQUIRED) add_library(dependencies INTERFACE) - target_link_libraries(dependencies INTERFACE ${CONAN_LIBS}) - target_compile_definitions(dependencies INTERFACE CONAN) + target_link_libraries( + dependencies + INTERFACE + fmt::fmt + nlohmann_json::nlohmann_json + httplib::httplib + concurrentqueue::concurrentqueue + ) + if(NOT REDUCT_CPP_USE_STD_CHRONO) + message(STATUS "Using date library") -else () + find_package(date REQUIRED) + target_link_libraries(dependencies INTERFACE date::date) + else() + message(STATUS "Using std::chrono") + endif() +else() message(STATUS "Conan not found. Fetch dependencies") include(FetchContent) FetchContent_Declare( - fmt - URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.zip - URL_HASH MD5=6e20923e12c4b78a99e528c802f459ef + fmt + URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.zip + URL_HASH MD5=6e20923e12c4b78a99e528c802f459ef ) FetchContent_Declare( - nlohmann_json - URL https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.zip - URL_HASH MD5=23712ebf3a4b4ccb39f2375521716ab3 + nlohmann_json + URL https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.zip + URL_HASH MD5=23712ebf3a4b4ccb39f2375521716ab3 ) FetchContent_Declare( - httplib - URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.16.0.zip - URL_HASH MD5=c5367889819d677bd06d6c7739896b2b + httplib + URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.16.0.zip + URL_HASH MD5=c5367889819d677bd06d6c7739896b2b ) FetchContent_Declare( - concurrentqueue - URL https://github.com/cameron314/concurrentqueue/archive/refs/tags/v1.0.4.zip - URL_HASH MD5=814c5e121b29e37ee836312f0eb0328f + concurrentqueue + URL + https://github.com/cameron314/concurrentqueue/archive/refs/tags/v1.0.4.zip + URL_HASH MD5=814c5e121b29e37ee836312f0eb0328f ) add_library(dependencies INTERFACE) FetchContent_MakeAvailable(fmt nlohmann_json httplib concurrentqueue) - target_link_libraries(dependencies INTERFACE fmt nlohmann_json httplib concurrentqueue) + target_link_libraries( + dependencies + INTERFACE fmt nlohmann_json httplib concurrentqueue + ) if(NOT REDUCT_CPP_USE_STD_CHRONO) FetchContent_Declare( - date - URL https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip - URL_HASH MD5=cf556cc376d15055b8235b05b2fc6253) + date + URL + https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.zip + URL_HASH MD5=cf556cc376d15055b8235b05b2fc6253 + ) FetchContent_MakeAvailable(date) target_link_libraries(dependencies INTERFACE date) endif() -endif () +endif() diff --git a/conanfile.py b/conanfile.py index 067d289..ea05bdd 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,46 +1,139 @@ -from conans import ConanFile, CMake +from os.path import join + +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy +from conan.tools.scm import Git class DriftFrameworkConan(ConanFile): name = "reduct-cpp" - version = "1.14.0" license = "MIT" author = "Alexey Timin" url = "https://github.com/reduct-storage/reduct-cpp" description = "Reduct Storage Client SDK for C++" topics = ("reduct-storage", "http-client", "http-api") settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True, "cpp-httplib:with_openssl": True, "cpp-httplib:with_zlib": True, - "date:header_only": True} - generators = "cmake" - - requires = ("fmt/11.0.2", - "cpp-httplib/0.16.0", - "nlohmann_json/3.11.3", - "openssl/3.2.2", - "concurrentqueue/1.0.4", - "date/3.0.1") + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_chrono": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_chrono": False, + "cpp-httplib/*:with_openssl": True, + "cpp-httplib/*:with_zlib": True, + "date/*:header_only": True, + } + + requires = ( + "fmt/11.0.2", + "cpp-httplib/0.16.0", + "nlohmann_json/3.11.3", + "openssl/3.2.2", + "concurrentqueue/1.0.4", + ) + + def set_version(self): + if not self.version: + git = Git(self, self.recipe_folder) + self.version = git.run("describe --tags") + ".local" def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + if self.settings.get_safe("os") == "Windows": + self.options.rm_safe("fPIC") + self.options.with_chrono = True + elif ( + self.settings.get_safe("compiler") == "gcc" + and self.settings.get_safe("compiler.version") >= "14" + ): + self.options.with_chrono = True + + def requirements(self): + if not self.options.with_chrono: + self.requires("date/3.0.1") + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + if self.options.with_chrono: + tc.variables["REDUCT_CPP_USE_STD_CHRONO"] = "ON" + tc.generate() + + def export_sources(self): + if ".local" in self.version: + copy( + self, + "CMakeLists.txt", + src=self.recipe_folder, + dst=self.export_sources_folder, + ) + copy( + self, "cmake/*", src=self.recipe_folder, dst=self.export_sources_folder + ) + copy(self, "src/*", src=self.recipe_folder, dst=self.export_sources_folder) def source(self): - self.run(f'git clone --branch v{self.version} https://github.com/reduct-storage/reduct-cpp.git') + if ".local" not in self.version: + git = Git(self) + git.clone( + url="https://github.com/reduct-storage/reduct-cpp.git", target="." + ) + git.checkout(f"v{self.version}") def build(self): cmake = CMake(self) - cmake.configure(source_dir='reduct-cpp') + cmake.configure() cmake.build() def package(self): - self.copy("*.h", dst="include/reduct", src=f"{self.source_folder}/reduct-cpp/src/reduct") - self.copy("*reductcpp.lib", dst="lib", keep_path=False) - self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.so", dst="lib", keep_path=False) - self.copy("*.dylib", dst="lib", keep_path=False) - self.copy("*.a", dst="lib", keep_path=False) + copy( + self, + "*.h", + dst=join(self.package_folder, "include", "reduct"), + src=join(self.source_folder, "src", "reduct"), + ) + copy( + self, + "*reductcpp.lib", + src=join(self.build_folder, "lib"), + dst=join(self.package_folder, "lib"), + keep_path=False, + ) + copy( + self, + "*.dll", + src=self.build_folder, + dst=join(self.package_folder, "bin"), + keep_path=False, + ) + copy( + self, + "*.so", + src=self.build_folder, + dst=join(self.package_folder, "lib"), + keep_path=False, + ) + copy( + self, + "*.dylib", + src=self.build_folder, + dst=join(self.package_folder, "lib"), + keep_path=False, + ) + copy( + self, + "*.a", + src=self.build_folder, + dst=join(self.package_folder, "lib"), + keep_path=False, + ) def package_info(self): self.cpp_info.libs = ["reductcpp"] diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0071286..8d5e818 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,11 +6,21 @@ set(CMAKE_CXX_STANDARD 20) find_package(ZLIB) find_package(OpenSSL) - - find_package(ReductCpp 1.12.0) add_executable(usage-example usage_example.cc) add_executable(subscription subscription.cc) -target_link_libraries(usage-example ${REDUCT_CPP_LIBRARIES} ${ZLIB_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) -target_link_libraries(subscription ${REDUCT_CPP_LIBRARIES} ${ZLIB_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) +target_link_libraries( + usage-example + ${REDUCT_CPP_LIBRARIES} + ${ZLIB_LIBRARIES} + OpenSSL::SSL + OpenSSL::Crypto +) +target_link_libraries( + subscription + ${REDUCT_CPP_LIBRARIES} + ${ZLIB_LIBRARIES} + OpenSSL::SSL + OpenSSL::Crypto +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a868531..074405d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,40 +1,59 @@ set(SRC_FILES - reduct/internal/http_client.cc - reduct/internal/serialisation.cc - reduct/bucket.cc - reduct/client.cc - reduct/error.cc) + reduct/internal/http_client.cc + reduct/internal/serialisation.cc + reduct/bucket.cc + reduct/client.cc + reduct/error.cc +) set(PUBLIC_HEADERS - reduct/bucket.h - reduct/client.h - reduct/error.h - reduct/http_options.h - reduct/result.h - reduct/diagnostics.h) - + reduct/bucket.h + reduct/client.h + reduct/error.h + reduct/http_options.h + reduct/result.h + reduct/diagnostics.h +) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") add_library(${CMAKE_PROJECT_NAME} STATIC ${SRC_FILES}) -target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../3dparty) +target_include_directories( + ${CMAKE_PROJECT_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) +target_include_directories( + ${CMAKE_PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../3dparty +) target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE dependencies) -set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") -target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT) +set_target_properties( + ${CMAKE_PROJECT_NAME} + PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}" +) +target_compile_definitions( + ${CMAKE_PROJECT_NAME} + PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT +) if(REDUCT_CPP_USE_STD_CHRONO) - target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE REDUCT_CPP_USE_STD_CHRONO) + target_compile_definitions( + ${CMAKE_PROJECT_NAME} + PRIVATE REDUCT_CPP_USE_STD_CHRONO + ) endif() include(GNUInstallDirs) -install(TARGETS ${CMAKE_PROJECT_NAME} - LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/reduct - ) - -install(FILES +install( + TARGETS ${CMAKE_PROJECT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/reduct +) + +install( + FILES "${CMAKE_BINARY_DIR}/cmake/ReductCppConfig.cmake" "${CMAKE_BINARY_DIR}/cmake/ReductCppConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}") + DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}" +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 156c755..7600d71 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,21 +5,26 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include(FetchContent) FetchContent_Declare( - Catch2 - URL https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.8.zip - URL_HASH MD5=78148e1a75aea786038fb8d21b9455f2 + Catch2 + URL https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.8.zip + URL_HASH MD5=78148e1a75aea786038fb8d21b9455f2 ) FetchContent_MakeAvailable(Catch2) - set(SRC_FILES - reduct/bucket_api_test.cc - reduct/entry_api_test.cc - reduct/replication_api_test.cc - reduct/server_api_test.cc - reduct/token_api_test.cc - test.cc) + reduct/bucket_api_test.cc + reduct/entry_api_test.cc + reduct/replication_api_test.cc + reduct/server_api_test.cc + reduct/token_api_test.cc + test.cc +) add_executable(reduct-tests ${SRC_FILES}) -target_link_libraries(reduct-tests ${CMAKE_PROJECT_NAME} dependencies Catch2::Catch2) +target_link_libraries( + reduct-tests + ${CMAKE_PROJECT_NAME} + dependencies + Catch2::Catch2 +)