Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a document page to build on Windows. #887

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ if (NOT MSVC)
set(EXTRA_CXX_FLAGS ${EXTRA_CXX_FLAGS} -Werror)
endif()

if("${BUILD_TYPE_LOWER}" MATCHES "debug")
message("debug mode was set")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unreachable-code")
else()
message("release mode was set")
if (NOT MSVC)
if("${BUILD_TYPE_LOWER}" MATCHES "debug")
message("debug mode was set")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unreachable-code")
else()
message("release mode was set")
endif()
endif()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand Down
128 changes: 128 additions & 0 deletions WINDOWS_BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

## Install on Windows

This document page describes a way to build rsocket-cpp with 'Visual Studio tools for CMake' in Visual Studio 2017 on Windows.

### Pre-Acquisition

#### Install Vcpkg

During the build process of rsocket-cpp, it requires [folly](https://github.com/facebook/folly) and it is available in [vcpkg](https://github.com/Microsoft/vcpkg#vcpkg).

#### Install CMake Tools

1. Run Visual Studio 2017.
* *it is recommended to use higher version than 15.4.5. due to the issue that 15.4 couldn't open CMake correctly.*
2. Select *Tools > Get Tools and Features...* menu.
3. Go to **Indivisual components** tab
4. See *'Compilers, build tools, and runtimes* and check **Visual C++ tools for CMake.**
5. See *'Development activities'* and check the followings:
* **Visual C++ for Linux Development.** *(Not sure though it is really necessary)*
* **Visual C++ tools for CMake and Linux.** *(Not sure though it is really necessary)*
6. Press 'Modify' button!

### Open CMake Project

1. Run Visual Studio 2017
2. Select *Open > File > CMake* menu then select *'CMakeList.txt'* file under the rsocket-cpp repository directory.
3. Select *CMake > Change_CMake_Settings > CMakeList.txt* menu, and it will generate **CMakeSettings.json** file.


#### CMakeSettings

The created CMakeSettings.json file will be opened automatically but it will be not, you have to do manually.

The first thing you need to do is changing the directory path of **buildRoot** and **installRoot** to have its directory under the repository directory.

Change
```"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",```
as
```"buildRoot": "${projectDir}\\build\\${name}",```

Next, change
``` "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", ```
as
```"installRoot": "${projectDir}\\install\\${name}",```

Now, all the files such as .obj, .lib, and .exe will be put under the changed directory in your repository directorys.

You might also need to change **cmakeCommandArgs** argument to be set "-DBUILD_TESTS=OFF" which disables google test. (due to the issue #869)

#### Install folly

Install [folly](https://github.com/facebook/folly) thorough [vcpkg](https://github.com/Microsoft/vcpkg#vcpkg).

Open command-line(cmd) window and move to where vcpkg.exe is and run the following:

```
.\vcpkg.exe install folly:x64-windows --head
```

After the installation, it has to be integrated to use the package in Visual Studio 2017. Run the following:
```
.\vcpkg.exe integrate install
```

To make the project can refer ***folly***, the external package, it needs to change CMakeSettings.json file. Add **variables** element and get it to have 'name' and 'value' like the following.

```json
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${project`Dir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "-DBUILD_TESTS=OFF",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "C:\\dev\\gRPC\\install\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
}
}
]
}
```
Save the modification and you can see CMakeCache is refreshed then it refers 'folly' package correctly.

Now you should see *Build* and other menu items under *CMake* menu but there are still a few things to be tweaked.


Open 'rsocket_repository/CMakeList.txt' file and go to line 177 and add ```if (NOT MSVC)``` so the change looks like the following:
```json
if (NOT MSVC)
if("${BUILD_TYPE_LOWER}" MATCHES "debug")
message("debug mode was set")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unreachable-code")
else()
message("release mode was set")
endif()
endif()
```
Without the above modification, it might meet the following error messasge when it built:
>`Error D8021 invalid numeric argument '/Wno-unreachable-code'


Open 'rsocket_repository/rsocket/benchmarks/CMakeList.txt' file. And add ```If (NOT MSVC)``` at the first line not to build entire benchmark related files. Don't forget to add ```endif()``` at the end of the line either. Now, it should look like the following:
```json
if (NOT MSVC`)
add_library(fixture Fixture.cpp Fixture.h)
target_link_libraries(fixture ReactiveSocket Folly::folly)
...
endif()
```
Without the above modification, it might meet the following error messasge when it built:
>Error C1083 Cannot open include file: 'arpa/inet.h': No such file or directory


### Build and Install

Now, you can go build and install all the libraries and examples.

*Note: All the above are tested on Visual Studio 2017 v15.9.11 in Windows10*
2 changes: 2 additions & 0 deletions rsocket/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (NOT MSVC)
add_library(fixture Fixture.cpp Fixture.h)
target_link_libraries(fixture ReactiveSocket Folly::folly)

Expand Down Expand Up @@ -27,3 +28,4 @@ add_test(NAME FireForgetThroughputTcpTest COMMAND fire-forget-throughput-tcp --i

#TODO(lehecka):enable test
#add_test(NAME StreamThroughputMemoryTest COMMAND stream-throughput-mem --items 100000)
endif()