From 757cc6c03baaa7a8dd8f56212794927611d52b61 Mon Sep 17 00:00:00 2001
From: Alex <akreft@trineo.org>
Date: Wed, 28 Jul 2021 10:30:13 +0200
Subject: [PATCH] Fix for compiling with Visual Studio

---
 CMakeLists.txt  | 13 +++++++++++--
 README_SETUP.md | 12 ++++++++++++
 conanfile.py    |  2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0131970..bd9222a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
 
+IF (WIN32)
+    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ENDIF()
+
 ###########################################
 ### DEPENDENCY MANAGEMENT with CONAN
 ###########################################
@@ -79,8 +83,13 @@ set(PROTO_FILES
 set(PROTO_PATH ${PROJECT_SOURCE_DIR}/proto/proto)
 
 # compiler binaries
-set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc")
-set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin")
+IF (WIN32)
+    set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc.exe")
+    set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin.exe")
+ELSE()
+    set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc")
+    set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin")
+ENDIF()
 
 # Generated sources
 list(LENGTH PROTO_FILES len_proto_files)
diff --git a/README_SETUP.md b/README_SETUP.md
index bcda25a..86546c9 100644
--- a/README_SETUP.md
+++ b/README_SETUP.md
@@ -29,6 +29,18 @@ have to add `build/lib/` (or, alternatively after installation,
 `CMAKE_INSTALL_PREFIX/lib`) to your `DYLD_LIBRARY_PATH` environmental
 variable.
 
+### How to build on Windows
+
+We use [Visual Studio 2019](https://visualstudio.microsoft.com/de/vs/features/cplusplus/) as compiler.
+We use [cmake](https://cmake.org/download/) as build tool.
+
+1. `mkdir build`
+2. `cd build`
+3. `conan install .. -g visual_studio -s arch=x86_64 -s build_type=Release -s compiler.toolset=v142 -s compiler.version=16 -s compiler.runtime=MD  --build=missing --update`
+4. `cmake -B . ..`
+5. open ` libcaosdb.sln` with Visual Studio, change the buildtype to `Release` and build the project.
+(You can open Tools/Command Line/Developer Command Prompt and execute `msbuild libcaosdb.sln /property:Configuration=Release`)  
+
 ## Unit Tests
 
 ### Build
diff --git a/conanfile.py b/conanfile.py
index 1ed1abd..5364e47 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -28,7 +28,7 @@ class CaosdbConan(ConanFile):
 
     def imports(self):
         self.copy("protoc*", "build_tools", "bin")
-        self.copy("grpc_cpp_plugin", "build_tools", "bin")
+        self.copy("grpc_cpp_plugin*", "build_tools", "bin")
 
     def build(self):
         cmake = CMake(self)
-- 
GitLab