Skip to content

Commit 6e3fcf6

Browse files
Chachaylava
authored andcommitted
Update windows/VS2017 support
1 parent 331029f commit 6e3fcf6

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

contrib/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.7)
22
project (MatplotlibCPP_Test)
33

44
set(CMAKE_CXX_STANDARD 11)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

77
include_directories(${PYTHONHOME}/include)
8+
include_directories(${PYTHONHOME}/Lib/site-packages/numpy/core/include)
89
link_directories(${PYTHONHOME}/libs)
910

1011
add_definitions(-DMATPLOTLIBCPP_PYTHON_HEADER=Python.h)
1112

1213
# message(STATUS "*** dump start cmake variables ***")
1314
# get_cmake_property(_variableNames VARIABLES)
1415
# foreach(_variableName ${_variableNames})
15-
# message(STATUS "${_variableName}=${${_variableName}}")
16+
# message(STATUS "${_variableName}=${${_variableName}}")
1617
# endforeach()
1718
# message(STATUS "*** dump end ***")
1819

1920
add_executable(minimal ${CMAKE_CURRENT_SOURCE_DIR}/../examples/minimal.cpp)
2021
add_executable(basic ${CMAKE_CURRENT_SOURCE_DIR}/../examples/basic.cpp)
2122
add_executable(modern ${CMAKE_CURRENT_SOURCE_DIR}/../examples/modern.cpp)
23+
add_executable(animation ${CMAKE_CURRENT_SOURCE_DIR}/../examples/animation.cpp)
24+
add_executable(nonblock ${CMAKE_CURRENT_SOURCE_DIR}/../examples/nonblock.cpp)
25+
add_executable(xkcd ${CMAKE_CURRENT_SOURCE_DIR}/../examples/xkcd.cpp)

contrib/README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,25 @@ contributors are not required to and may be unable to check whether their
88
changes break any of them.
99

1010
## Windows support
11+
Tested on the following environment
12+
* Windows 10 - 64bit
13+
* Anaconda 4.3 (64 bit)
14+
* Python 3.6.0
15+
* CMake 3.9.4
16+
* Visual Studio 2017, 2015, 2013
1117

1218
### Configuring and Building Samples
19+
1. Edit WinBuild.cmd for your environment(Line:5-7)
20+
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=[Your Visual Studio Version(12, 14, 15)]
21+
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
22+
if NOT DEFINED PYTHONHOME set PYTHONHOME=[Your Python Path]
1323

24+
2. Run WinBuild.cmd to build
1425
```cmd
1526
> cd contrib
1627
> WinBuild.cmd
1728
```
18-
1929
The `WinBuild.cmd` will set up temporal ENV variables and build binaries in (matplotlib root)/examples with the Release configuration.
30+
31+
3. Find exe files in examples/build/Release
32+
Note: platforms folder is necessary to make qt works.

contrib/WinBuild.cmd

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
@echo off
22
@setlocal EnableDelayedExpansion
33

4-
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
4+
REM ------Set Your Environment-------------------------------
5+
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=15
56
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
67
if NOT DEFINED PYTHONHOME set PYTHONHOME=C:/Users/%username%/Anaconda3
8+
REM ---------------------------------------------------------
9+
10+
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7"
11+
set VALUE_NAME=15.0
712

813
if "%MSVC_VERSION%"=="14" (
914
if "%processor_architecture%" == "AMD64" (
@@ -14,13 +19,23 @@ if "%MSVC_VERSION%"=="14" (
1419
) else if "%MSVC_VERSION%"=="12" (
1520
if "%processor_architecture%" == "AMD64" (
1621
set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
17-
1822
) else (
1923
set CMAKE_GENERATOR=Visual Studio 12 2013
2024
)
25+
) else if "%MSVC_VERSION%"=="15" (
26+
if "%processor_architecture%" == "AMD64" (
27+
set CMAKE_GENERATOR=Visual Studio 15 2017 Win64
28+
) else (
29+
set CMAKE_GENERATOR=Visual Studio 15 2017
30+
)
31+
)
32+
if "%MSVC_VERSION%"=="15" (
33+
for /F "usebackq tokens=1,2,*" %%A in (`REG QUERY %KEY_NAME% /v %VALUE_NAME%`) do (
34+
set batch_file=%%CVC\Auxiliary\Build\vcvarsall.bat
35+
)
36+
) else (
37+
set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat
2138
)
22-
23-
set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat
2439
call "%batch_file%" %processor_architecture%
2540

2641
pushd ..

examples/xkcd.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#define _USE_MATH_DEFINES
2+
#include <cmath>
13
#include "../matplotlibcpp.h"
24
#include <vector>
3-
#include <cmath>
45

56
namespace plt = matplotlibcpp;
67

0 commit comments

Comments
 (0)