diff --git a/CMakeLists.txt b/CMakeLists.txt index c8f7292bd2afd194d532a198f73e3c6d2c36c92a..618c6dd586165e4fd74f188bd7b7751656f9704c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,9 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) IF (WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -ENDIF() + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # suppress warnings for fopen, strcpy, etc. +endif() + IF (BUILD_ACM) message(STATUS "BUILD_ACM") @@ -370,7 +372,12 @@ endif() set(liblinkahead_INCLUDE_DEST "include/linkahead") set(liblinkahead_LIB_DEST "lib") -set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local/") +if (WIN32) + set(CMAKE_INSTALL_PREFIX "$ENV{APPDATA}/LinkAhead") +else() + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local/") +endif() + install( # targets to install TARGETS linkahead clinkahead caosdb_grpc @@ -380,6 +387,7 @@ install( # "make install" LIBRARY DESTINATION ${liblinkahead_LIB_DEST} ARCHIVE DESTINATION ${liblinkahead_LIB_DEST} + RUNTIME DESTINATION ${liblinkahead_LIB_DEST} # This line ensures DLLs are copied on Windows INCLUDES DESTINATION ${liblinkahead_INCLUDE_DEST} ) diff --git a/conanfile.py b/conanfile.py index 7b62c09f9146b2269781766f379abce39af2ff24..7428fc8b0cdc2e40db719e3755c00f305a742f93 100644 --- a/conanfile.py +++ b/conanfile.py @@ -71,7 +71,7 @@ class LinkAheadConan(ConanFile): cmake = CMake(self) cmake.configure() - cmake.build(target=["all"]) # , "clinkaheadcli", "cxxlinkaheadcli"]) + cmake.build() def package(self): cmake = CMake(self) @@ -96,8 +96,19 @@ class LinkAheadConan(ConanFile): dst=os.path.join(self.package_folder, "lib"), keep_path=False) def package_info(self): - self.cpp_info.libs = ["linkahead", "clinkahead" ] + self.cpp_info.libs = ["linkahead::linkahead", "linkahead::clinkahead", "linkahead::caosdb_grpc" ] self.cpp_info.requires = ["boost::headers", "grpc::grpc", "protobuf::protobuf"] + self.cpp_info.bindirs = ["build/Release", "build/Debug"] + self.cpp_info.includedirs = ["include", "build/include"] + self.cpp_info.components["linkahead::linkahead"].libs = ["linkahead"] + self.cpp_info.components["linkahead::linkahead"].set_property("cmake_target_name", "linkahead") + + self.cpp_info.components["linkahead::clinkahead"].libs = ["clinkahead"] + self.cpp_info.components["linkahead::clinkahead"].set_property("cmake_target_name", "clinkahead") + + self.cpp_info.components["linkahead::caosdb_grpc"].libs = ["caosdb_grpc"] + self.cpp_info.components["linkahead::caosdb_grpc"].set_property("cmake_target_name", "caosdb_grpc") + def validate(self): if self.settings.os not in ("Linux", "Windows"): diff --git a/doc/Install_develop.rst b/doc/Install_develop.rst index 8661d8bf4ccd5d29cdaab98e752c7b1cded68239..255fd2f66d47ae86a9daa5ff120b66e6f3ca38c6 100644 --- a/doc/Install_develop.rst +++ b/doc/Install_develop.rst @@ -65,7 +65,7 @@ commands: vcpkg/vcpkg install -Copy the ``grpc-cpp-plugin`` to the build directory (TODO: This should ideally be done automatically by CMake): +Copy the ``grpc-cpp-plugin`` to the build directory (TODO: This should ideally be done automatically by CMake): .. code:: console @@ -83,7 +83,7 @@ Then compile the project with CMake by including the vcpkg toolchain file: Alternatively, on Linux, you can use the provided `Makefile` targets .. code:: console - + make vcpkg-build-release @@ -108,7 +108,7 @@ How to build on Windows We use `Visual Studio 2022 <https://visualstudio.microsoft.com/de/vs/features/cplusplus/>`__ as compiler. We use `cmake <https://cmake.org/download/>`__ as build -tool, which can be installed together with Visual Studio. +tool, which can be installed together with Visual Studio. 1. Install Python and create a virtual environment with the dependencies in `requirements.txt`. @@ -128,7 +128,7 @@ Troubleshooting ERROR: The default build profile '~/.conan2/profiles/default' doesn't exist ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Follow the instructions and run +Follow the instructions and run .. code:: console @@ -175,6 +175,18 @@ to, e.g., ``std::string_view`` being unavailable, try specifying the cpp standard manually by ``conan install .. [other options] -s "compiler.cppstd=17"``. +Problems with symlinks on Windows +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you're experiencing problems with symlinks, e.g., errors like `` +\linkahead-cpplib\test_package\test_info.cpp(1,1): error C2059: syntax +error '.'`` when running ``conan create`` on Windows you might need to +activate the Windows Development Mode and adjust yor git config to +allow symlinks as described in `this Stackoverflow post +<https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201#59761201>`_. Without +development mode and the proper git configuration, windows treats +symlinks as text files instead of links. + Client Configuration -------------------- @@ -220,7 +232,7 @@ For the tests the build type has to be Debug. As a shorthand you can run ``make test``. If you want to build manually, follow these steps: 1. ``conan install . -s build_type=Debug --build=missing`` -2. ``cd build/Debug`` +2. ``cd build/Debug`` 3. ``cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug`` - If your clang-format version is too old, formatting, linting etc. can be skipped: diff --git a/include/linkahead/result_set.h b/include/linkahead/result_set.h index 0ada000f0faaec395ace73f725d504f44a473dc4..d8181fd0c4fe686d529afe7f075f126c20beb1f2 100644 --- a/include/linkahead/result_set.h +++ b/include/linkahead/result_set.h @@ -40,7 +40,7 @@ class ResultSet { public: virtual ~ResultSet() = default; - [[nodiscard]] virtual auto size() const noexcept -> int = 0; + [[nodiscard]] virtual auto size() const noexcept -> size_t = 0; [[nodiscard]] virtual auto at(const int index) const -> const Entity & = 0; [[nodiscard]] virtual auto mutable_at(int index) const -> Entity * = 0; /** @@ -91,7 +91,7 @@ public: virtual ~AbstractMultiResultSet() = default; inline explicit AbstractMultiResultSet(std::vector<std::unique_ptr<Entity>> result_set) : items(std::move(result_set)) {} - [[nodiscard]] inline auto size() const noexcept -> int override { return this->items.size(); } + [[nodiscard]] inline auto size() const noexcept -> size_t override { return this->items.size(); } [[nodiscard]] inline auto at(const int index) const -> const Entity & override { return *(this->items.at(index)); } diff --git a/make.ps1 b/make.ps1 index 64d73e62b3d5d710cd6e2378679bb3bb743a29ea..5bbadaf9aba2a89d66e65ec234d0bc9627d66cbb 100644 --- a/make.ps1 +++ b/make.ps1 @@ -2,6 +2,9 @@ param ( [string]$target ) +$buildType = "Release" +$cppStd=17 + function Install-Conan { Write-Output "Installing Release dependencies with Conan..." # check if conan is available @@ -9,11 +12,11 @@ function Install-Conan { Write-Output "Conan is not available. Please install Conan or activate the Conan environment venv" exit 1 } - conan install . --build=missing -s build_type=Release -s compiler.cppstd=17 + conan install . --build=missing -s build_type=$buildType -s compiler.cppstd=$cppStd cmake --preset conan-default } -function Build-Project { +function Invoke-Build { Write-Output "Building the project..." # check if msbuild is available if (-not (Get-Command msbuild -ErrorAction SilentlyContinue)) { @@ -25,7 +28,7 @@ function Build-Project { Write-Output "Please run conan-install first." exit 1 } - msbuild .\build\liblinkahead.sln /property:Configuration=Release + msbuild .\build\liblinkahead.sln /property:Configuration=$buildType } function Invoke-Tests { @@ -37,6 +40,12 @@ function Invoke-Tests { } Set-Location .\build\ ctest + Set-Location ..\ +} + +function Invoke-Create { + Write-Output "Creating Conan package..." + conan create . } # check if vswhere is available @@ -57,7 +66,7 @@ Set-Location $currentPath switch ($target) { "build" { - Build-Project + Invoke-Build } "test" { Invoke-Tests @@ -65,16 +74,20 @@ switch ($target) { "conan-install" { Install-Conan } + "conan-create" { + Invoke-Create + } "clean"{ Write-Output "Cleaning the project..." Remove-Item -Recurse -Force .\build\* } "all" { Install-Conan - Build-Project + Invoke-Build Invoke-Tests + Invoke-Create } default { - Write-Output "Usage: .\make.ps1 [all|conan-install|build|test|clean]" + Write-Output "Usage: .\make.ps1 [all|conan-install|conan-create|build|test|clean]" } } diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 371a0b947266f2ac2e61e82c81a94cf904dfb36c..a11332c293a36f3859605aa9bdc3e36e70269409 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -13,8 +13,9 @@ set(test_cases ################################################### -find_package(linkahead REQUIRED) -find_package(GTest REQUIRED) +find_package(linkahead CONFIG REQUIRED) +find_package(GTest CONFIG REQUIRED) +find_package(Protobuf CONFIG REQUIRED) # supress warnings during build of gtest cmake_policy(SET CMP0054 NEW) @@ -25,7 +26,10 @@ include(GoogleTest REQUIRED) # loop over all test cases and add them to the test runner add_executable(test_info test_info.cpp) -target_link_libraries(test_info PRIVATE GTest::gtest GTest::gtest_main linkahead::linkahead) +target_link_libraries(test_info PRIVATE + GTest::gtest GTest::gtest_main + linkahead::linkahead caosdb_grpc clinkahead + protobuf::protobuf) gtest_discover_tests(test_info) # foreach(test_case ${test_cases})