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

Merge branch 'f-windows-conan-create' into 'dev'

Fix conan create on Windows

See merge request !58
parents 625204c2 ed0fb02b
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!58Fix conan create on Windows
Pipeline #57469 passed with warnings
Pipeline: caosdb-cppinttest

#57477

    ......@@ -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}
    )
    ......
    ......@@ -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"):
    ......
    ......@@ -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:
    ......
    ......@@ -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));
    }
    ......
    ......@@ -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]"
    }
    }
    ......@@ -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})
    ......
    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