From cce85f3ba8f782b3288bb169fb72e6e160955c83 Mon Sep 17 00:00:00 2001 From: Nicolas Riebesel Date: Thu, 14 Jun 2018 01:17:38 +0200 Subject: [PATCH] Add Visual Studio 2017 support (#336) --- .gitignore | 5 +++++ CMakeLists.txt | 18 ++++++++--------- CMakeSettings.json | 38 ++++++++++++++++++++++++++++++++++++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 CMakeSettings.json diff --git a/.gitignore b/.gitignore index cb860801..0b430f07 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,11 @@ Icon .Trashes .VolumeIcon.icns +# Visual Studio +.vs +build-vc +vcpkg + # Directories potentially created on remote AFP share .AppleDB .AppleDesktop diff --git a/CMakeLists.txt b/CMakeLists.txt index fffe0f7d..99e8cfe8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,12 +37,7 @@ include(LMDB) # # Discover Qt dependencies. # -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Network REQUIRED) -find_package(Qt5LinguistTools REQUIRED) -find_package(Qt5Concurrent REQUIRED) -find_package(Qt5Svg REQUIRED) -find_package(Qt5Multimedia REQUIRED) +find_package(Qt5 COMPONENTS Core Widgets Network LinguistTools Concurrent Svg Multimedia REQUIRED) if (APPLE) find_package(Qt5MacExtras REQUIRED) @@ -58,20 +53,23 @@ endif(Qt5Widgets_FOUND) # # Set up compiler flags. # -set(CMAKE_C_COMPILER gcc) +if (NOT MSVC) + set(CMAKE_C_COMPILER gcc) +endif(NOT MSVC) + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) include(CompilerFlags) -if(NOT CMAKE_BUILD_TYPE) +if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) message("Setting build type to '${CMAKE_BUILD_TYPE}'") -else(NOT CMAKE_BUILD_TYPE) +else(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) message("Build type set to '${CMAKE_BUILD_TYPE}'") -endif(NOT CMAKE_BUILD_TYPE) +endif(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) find_program(GIT git) if(GIT) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 00000000..c90f6655 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,38 @@ +{ + "configurations": [ + { + "name": "Debug", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Debug", + "buildRoot": "${workspaceRoot}\\build-vc\\${name}", + "cmakeCommandArgs": "", + "variables": [ + { + "name": "CMAKE_TOOLCHAIN_FILE", + "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here + }, + { + "name": "Qt5_DIR", + "value": "C:\\Qt\\5.10.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here + } + ] + }, + { + "name": "Release", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Release", + "buildRoot": "${workspaceRoot}\\build-vc\\${name}", + "cmakeCommandArgs": "", + "variables": [ + { + "name": "CMAKE_TOOLCHAIN_FILE", + "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here + }, + { + "name": "Qt5_DIR", + "value": "C:\\Qt\\5.10.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here + } + ] + }, + ] +} \ No newline at end of file diff --git a/README.md b/README.md index c71b5ed6..fc6afab8 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,25 @@ brew update brew install qt5 lmdb cmake llvm ``` +##### Windows + +1. Install Visual Studio 2017's "Desktop Development" and "Linux Development with C++" +(for the CMake integration) workloads. + +2. Download the latest Qt for windows installer and install it somewhere. +Make sure to install the `MSVC 2017 64-bit` toolset for at least Qt 5.9 +(lower versions does not support VS2017). + +3. Install lmdb and openssl with `vcpkg`. You can simply clone it into a subfolder +of the root nheko source directory. + +```powershell +git clone http:\\github.com\Microsoft\vcpkg +cd vcpkg +.\bootstrap-vcpkg.bat +.\vcpkg install --triplet x64-windows lmdb openssl +``` + ### Building Clone the repo and run @@ -161,6 +180,35 @@ in the project folder. This will output a binary to `result/bin/nheko`. You can also install nheko by running `nix-env -f . -i` +#### Windows + +After installing all dependencies, you need to edit the `CMakeSettings.json` to +be able to load and compile nheko within Visual Studio. + +You need to fill out the paths for the `CMAKE_TOOLCHAIN_FILE` and the `Qt5_DIR`. +The toolchain file should point to the `vcpkg.cmake` and the Qt5 dir to the `lib\cmake\Qt5` dir. + +Examples for the paths are: + - `C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake` + - `C:\\Qt\\5.10.1\\msvc2017_64\\lib\\cmake\\Qt5` + +Now right click into the root nheko source directory and choose `Open in Visual Studio`. +You can choose the build type Release and Debug in the top toolbar. +After a successful CMake generation you can select the `nheko.exe` as the run target. +Now choose `Build all` in the CMake menu or press `F7` to compile the executable. + +To be able to run the application the last step is to install the needed Qt dependencies next to the +nheko binary. + +Start the "Qt x.xx.x 64-bit for Desktop (MSVC 2017)" command promt and run `windeployqt`. +```cmd +cd \build-vc\Release\Release +windeployqt nheko.exe +``` + +The final binary will be located inside `build-vc\Release\Release` for the Release build +and `build-vc\Debug\Debug` for the Debug build. + ### Contributing See [CONTRIBUTING](.github/CONTRIBUTING.md)