Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbedd3b

Browse files
committed
[Update] Installation on Windows using Visual Studio nmake
1 parent 2788e8b commit fbedd3b

File tree

11 files changed

+91
-277
lines changed

11 files changed

+91
-277
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 18 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,19 @@
11
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
2-
project(matplotlib_cpp LANGUAGES CXX)
3-
4-
include(GNUInstallDirs)
5-
set(PACKAGE_NAME matplotlib_cpp)
6-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${PACKAGE_NAME}/cmake)
7-
8-
9-
# Library target
10-
add_library(matplotlib_cpp INTERFACE)
11-
target_include_directories(matplotlib_cpp
12-
INTERFACE
13-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/examples>
14-
$<INSTALL_INTERFACE:include>
15-
)
16-
target_compile_features(matplotlib_cpp INTERFACE
17-
cxx_std_14
18-
)
19-
# TODO: Use `Development.Embed` component when requiring cmake >= 3.18
20-
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
21-
target_link_libraries(matplotlib_cpp INTERFACE
22-
Python3::Python
23-
Python3::Module
24-
)
25-
find_package(Python3 COMPONENTS NumPy)
26-
if(Python3_NumPy_FOUND)
27-
target_link_libraries(matplotlib_cpp INTERFACE
28-
Python3::NumPy
29-
)
30-
else()
31-
target_compile_definitions(matplotlib_cpp INTERFACE WITHOUT_NUMPY)
32-
endif()
33-
install(
34-
TARGETS matplotlib_cpp
35-
EXPORT install_targets
36-
)
37-
38-
find_package(PythonLibs 3.8)
39-
message("-- python is in ${Python3_NumPy_INCLUDE_DIRS}")
40-
41-
# Examples
42-
add_executable(minimal examples/minimal.cpp)
43-
target_link_libraries(minimal PRIVATE matplotlib_cpp)
44-
set_target_properties(minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
45-
46-
# add_executable(basic examples/basic.cpp)
47-
# target_link_libraries(basic PRIVATE matplotlib_cpp)
48-
# set_target_properties(basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
49-
50-
# add_executable(modern examples/modern.cpp)
51-
# target_link_libraries(modern PRIVATE matplotlib_cpp)
52-
# set_target_properties(modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
53-
54-
# add_executable(animation examples/animation.cpp)
55-
# target_link_libraries(animation PRIVATE matplotlib_cpp)
56-
# set_target_properties(animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
57-
58-
# add_executable(nonblock examples/nonblock.cpp)
59-
# target_link_libraries(nonblock PRIVATE matplotlib_cpp)
60-
# set_target_properties(nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
61-
62-
# add_executable(xkcd examples/xkcd.cpp)
63-
# target_link_libraries(xkcd PRIVATE matplotlib_cpp)
64-
# set_target_properties(xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
65-
66-
# add_executable(bar examples/bar.cpp)
67-
# target_link_libraries(bar PRIVATE matplotlib_cpp)
68-
# set_target_properties(bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
69-
70-
# add_executable(fill_inbetween examples/fill_inbetween.cpp)
71-
# target_link_libraries(fill_inbetween PRIVATE matplotlib_cpp)
72-
# set_target_properties(fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
73-
74-
# add_executable(fill examples/fill.cpp)
75-
# target_link_libraries(fill PRIVATE matplotlib_cpp)
76-
# set_target_properties(fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
77-
78-
# add_executable(update examples/update.cpp)
79-
# target_link_libraries(update PRIVATE matplotlib_cpp)
80-
# set_target_properties(update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
81-
82-
# add_executable(subplot2grid examples/subplot2grid.cpp)
83-
# target_link_libraries(subplot2grid PRIVATE matplotlib_cpp)
84-
# set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
85-
86-
# add_executable(lines3d examples/lines3d.cpp)
87-
# target_link_libraries(lines3d PRIVATE matplotlib_cpp)
88-
# set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
89-
90-
# if(Python3_NumPy_FOUND)
91-
# add_executable(surface examples/surface.cpp)
92-
# target_link_libraries(surface PRIVATE matplotlib_cpp)
93-
# set_target_properties(surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
94-
95-
# add_executable(colorbar examples/colorbar.cpp)
96-
# target_link_libraries(colorbar PRIVATE matplotlib_cpp)
97-
# set_target_properties(colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
98-
# add_executable(contour examples/contour.cpp)
99-
# target_link_libraries(contour PRIVATE matplotlib_cpp)
100-
# set_target_properties(contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
101-
102-
# add_executable(spy examples/spy.cpp)
103-
# target_link_libraries(spy PRIVATE matplotlib_cpp)
104-
# set_target_properties(spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
105-
# endif()
106-
107-
108-
# Install headers
109-
install(FILES
110-
"${PROJECT_SOURCE_DIR}/matplotlibcpp.h"
111-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
112-
113-
114-
# Install targets file
115-
install(EXPORT install_targets
116-
FILE
117-
${PACKAGE_NAME}Targets.cmake
118-
NAMESPACE
119-
${PACKAGE_NAME}::
120-
DESTINATION
121-
${INSTALL_CONFIGDIR}
122-
)
123-
124-
125-
# Install matplotlib_cppConfig.cmake
126-
include(CMakePackageConfigHelpers)
127-
configure_package_config_file(
128-
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PACKAGE_NAME}Config.cmake.in
129-
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake
130-
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
131-
)
132-
install(FILES
133-
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake
134-
DESTINATION ${INSTALL_CONFIGDIR}
135-
)
2+
project(matplotlib_cpp)
3+
message("Install path is ${CMAKE_INSTALL_PREFIX}")
4+
message("Build type is ${CMAKE_BUILD_TYPE}")
5+
6+
install(FILES ${CMAKE_SOURCE_DIR}/matplotlibcpp.h DESTINATION include)
7+
8+
set(matplotlib_cpp_include_dirs ${CMAKE_INSTALL_PREFIX}/include)
9+
configure_file(${CMAKE_SOURCE_DIR}/cmake/matplotlib_cppConfig.cmake.in
10+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/matplotlib_cppConfig.cmake" @ONLY)
11+
install(FILES
12+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/matplotlib_cppConfig.cmake"
13+
DESTINATION share/matplotlib_cpp/cmake)
14+
15+
# set(BUILD_TESTING 1)
16+
if(BUILD_TESTING)
17+
message("Build examples")
18+
include(${CMAKE_SOURCE_DIR}/cmake/examples.cmake)
19+
endif()

cmake/examples.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
find_package(matplotlib_cpp REQUIRED)
2+
add_compile_options(/MT)
3+
4+
link_libraries(${matplotlib_LIBS})
5+
6+
# Examples
7+
add_executable(minimal examples/minimal.cpp)
8+
set_target_properties(minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
9+
10+
add_executable(basic examples/basic.cpp)
11+
set_target_properties(basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
12+
13+
add_executable(modern examples/modern.cpp)
14+
set_target_properties(modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
15+
16+
add_executable(animation examples/animation.cpp)
17+
set_target_properties(animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
18+
19+
add_executable(nonblock examples/nonblock.cpp)
20+
set_target_properties(nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
21+
22+
add_executable(xkcd examples/xkcd.cpp)
23+
set_target_properties(xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
24+
25+
add_executable(bar examples/bar.cpp)
26+
set_target_properties(bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
27+
28+
add_executable(fill_inbetween examples/fill_inbetween.cpp)
29+
set_target_properties(fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
30+
31+
add_executable(fill examples/fill.cpp)
32+
set_target_properties(fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
33+
34+
add_executable(update examples/update.cpp)
35+
set_target_properties(update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
36+
37+
add_executable(subplot2grid examples/subplot2grid.cpp)
38+
set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
39+
40+
add_executable(lines3d examples/lines3d.cpp)
41+
set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
42+
43+
add_executable(surface examples/surface.cpp)
44+
set_target_properties(surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
45+
46+
add_executable(colorbar examples/colorbar.cpp)
47+
set_target_properties(colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
48+
49+
add_executable(contour examples/contour.cpp)
50+
set_target_properties(contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
51+
52+
add_executable(spy examples/spy.cpp)
53+
set_target_properties(spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

cmake/matplotlib_cppConfig.cmake.in

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
get_filename_component(matplotlib_cpp_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
1+
if(NOT DEFINED matplotlib_cpp_FOUND)
2+
set(matplotlib_cpp_FOUND 1)
3+
set(matplotlib_cpp_INCLUDE_DIRS "@matplotlib_cpp_include_dirs@")
24

3-
if(NOT TARGET matplotlib_cpp::matplotlib_cpp)
4-
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
5+
find_package(PythonLibs 3.8 REQUIRED)
56
find_package(Python3 COMPONENTS NumPy)
6-
include("${matplotlib_cpp_CMAKE_DIR}/matplotlib_cppTargets.cmake")
77

8-
get_target_property(matplotlib_cpp_INCLUDE_DIRS matplotlib_cpp::matplotlib_cpp INTERFACE_INCLUDE_DIRECTORIES)
8+
include_directories(
9+
${matplotlib_cpp_INCLUDE_DIRS}
10+
${PYTHON_INCLUDE_DIRS}
11+
${Python3_NumPy_INCLUDE_DIRS}
12+
)
913

14+
set(matplotlib_LIBS ${PYTHON_LIBRARIES})
15+
list(GET matplotlib_LIBS 0 2 3 REMOVE_STR)
16+
remove(matplotlib_LIBS ${REMOVE_STR})
17+
18+
message("--- [matplotlib_cpp]: Found! Already include required directories! Please link matplotlib_LIBS with /MT options.")
1019
endif()

contrib/Dockerfile

Lines changed: 0 additions & 27 deletions
This file was deleted.

contrib/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

contrib/README.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

contrib/WinBuild.cmd

Lines changed: 0 additions & 61 deletions
This file was deleted.

examples/basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#define _USE_MATH_DEFINES
22
#include <iostream>
33
#include <cmath>
4-
#include "../matplotlibcpp.h"
4+
#include <matplotlibcpp.h>
55

66
namespace plt = matplotlibcpp;
77

examples/minimal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../matplotlibcpp.h"
1+
#include <matplotlibcpp.h>
22

33
namespace plt = matplotlibcpp;
44

0 commit comments

Comments
 (0)