@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
2
2
3
3
project (
4
4
"matplotlibcpp17"
5
- VERSION 1.0.0
5
+ VERSION 1.0.4
6
6
DESCRIPTION
7
7
"A C++ header-only plotting library based on pybind11 and matplotlib, featuring more flexibility than matplotlibcpp"
8
8
HOMEPAGE_URL "https://soblin.github.io/matplotlibcpp17/" )
@@ -13,13 +13,14 @@ find_package(
13
13
REQUIRED )
14
14
find_package (pybind11 2.4.3 REQUIRED )
15
15
16
- # check matplotlib minor version
16
+ # ##############################################################################
17
+ # (1) check matplotlib minor version
18
+ # ##############################################################################
17
19
execute_process (
18
20
COMMAND ${Python3_EXECUTABLE} "-c" "import matplotlib;
19
21
print(str(matplotlib.__version__), end='')"
20
22
RESULT_VARIABLE MATPLOTLIB_VERSION_CHECKING
21
23
OUTPUT_VARIABLE MATPLOTLIB_VERSION )
22
-
23
24
if (NOT MATPLOTLIB_VERSION_CHECKING MATCHES 0 )
24
25
message (FATAL_ERROR "Could not check matplotlib.__version__" )
25
26
endif ()
@@ -32,55 +33,15 @@ else()
32
33
set (MATPLOTLIB_MINOR_VER_GTE_4 1 )
33
34
endif ()
34
35
35
- # gallery
36
- if (NOT DEFINED USE_GUI )
37
- set (USE_GUI 0 )
38
- message (STATUS "set USE_GUI = OFF" )
39
- endif ()
40
- if (NOT DEFINED ADD_DEMO )
41
- set (ADD_DEMO 0 )
42
- message (STATUS "set ADD_DEMO = OFF" )
43
- endif ()
44
- if (USE_GUI )
45
- message (STATUS "USE_GUI = ON" )
46
- else ()
47
- message (STATUS "USE_GUI = OFF" )
48
- endif ()
49
- if (ADD_DEMO )
50
- message (STATUS "ADD_DEMO = ON" )
51
- else ()
52
- message (STATUS "ADD_DEMO = OFF" )
53
- endif ()
54
-
55
- function (add_demo name path )
56
- add_executable (${name} ${path} )
57
- target_include_directories (${name} PUBLIC ${Python3_INCLUDE_DIRS}
58
- ${matplotlibcpp17_INCLUDE_DIRS} )
59
- target_link_libraries (${name} ${Python3_LIBRARIES} pybind11::embed xtensor )
60
- endfunction ()
61
-
62
- if (${ADD_DEMO} )
63
- find_package (
64
- Python3
65
- COMPONENTS NumPy
66
- REQUIRED )
67
- find_package (xtensor 0.24.0 REQUIRED )
68
- set (CMAKE_CXX_STANDARD 17 )
69
- set (CMAKE_CXX_FLAGS
70
- "-Wall -g -DUSE_GUI=${USE_GUI} -DMATPLOTLIB_MINOR_VER_GTE_4=${MATPLOTLIB_MINOR_VER_GTE_4} "
71
- )
72
- add_subdirectory (gallery/tests )
73
- add_subdirectory (gallery/lines_bars_and_markers )
74
- add_subdirectory (gallery/subplots_axes_and_figures )
75
- add_subdirectory (gallery/statistics )
76
- add_subdirectory (gallery/images_contours_and_fields )
77
- add_subdirectory (gallery/shapes_and_collections )
78
- add_subdirectory (gallery/artist_animation )
79
- add_subdirectory (gallery/mplot3d )
80
- add_subdirectory (gallery/scales )
81
- endif ()
36
+ target_include_directories (
37
+ ${PROJECT_NAME}
38
+ INTERFACE $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
39
+ $< INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} > )
40
+ target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_17 )
82
41
83
- # for add_subdirectory
42
+ # ##############################################################################
43
+ # (2) for add_subdirectory
44
+ # ##############################################################################
84
45
add_library (matplotlibcpp17::matplotlibcpp17 INTERFACE IMPORTED GLOBAL )
85
46
set_property (
86
47
TARGET matplotlibcpp17::matplotlibcpp17
@@ -90,14 +51,13 @@ set_property(
90
51
TARGET matplotlibcpp17::matplotlibcpp17
91
52
PROPERTY INTERFACE_LINK_LIBRARIES ${Python3_LIBRARIES} pybind11::embed )
92
53
93
- # install https://dominikberner.ch/cmake-interface-lib/
54
+ # ##############################################################################
55
+ # (3) install
56
+ # ##############################################################################
57
+ # https://dominikberner.ch/cmake-interface-lib/
94
58
include (GNUInstallDirs )
59
+ # header-only library(INTERFACE)
95
60
add_library (${PROJECT_NAME} INTERFACE )
96
- target_include_directories (
97
- ${PROJECT_NAME}
98
- INTERFACE $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
99
- $< INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} > )
100
- target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_17 )
101
61
install (
102
62
TARGETS ${PROJECT_NAME}
103
63
EXPORT ${PROJECT_NAME} _Targets
@@ -129,6 +89,9 @@ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
129
89
# create .deb
130
90
include ("${PROJECT_SOURCE_DIR} /cmake/package.cmake" )
131
91
92
+ # ##############################################################################
93
+ # (4) uninstall
94
+ # ##############################################################################
132
95
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
133
96
if (NOT TARGET uninstall )
134
97
configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /cmake/uninstall.cmake.in"
@@ -137,3 +100,53 @@ if(NOT TARGET uninstall)
137
100
uninstall COMMAND ${CMAKE_COMMAND} -P
138
101
${CMAKE_CURRENT_BINARY_DIR} /uninstall.cmake )
139
102
endif ()
103
+
104
+ # ##############################################################################
105
+ # (5) gallery
106
+ # ##############################################################################
107
+ if (NOT DEFINED USE_GUI )
108
+ set (USE_GUI 0 )
109
+ message (STATUS "set USE_GUI = OFF" )
110
+ endif ()
111
+ if (NOT DEFINED ADD_DEMO )
112
+ set (ADD_DEMO 0 )
113
+ message (STATUS "set ADD_DEMO = OFF" )
114
+ endif ()
115
+ if (USE_GUI )
116
+ message (STATUS "USE_GUI = ON" )
117
+ else ()
118
+ message (STATUS "USE_GUI = OFF" )
119
+ endif ()
120
+ if (ADD_DEMO )
121
+ message (STATUS "ADD_DEMO = ON" )
122
+ else ()
123
+ message (STATUS "ADD_DEMO = OFF" )
124
+ endif ()
125
+
126
+ function (add_demo name path )
127
+ add_executable (${name} ${path} )
128
+ target_include_directories (${name} PUBLIC ${Python3_INCLUDE_DIRS}
129
+ ${matplotlibcpp17_INCLUDE_DIRS} )
130
+ target_link_libraries (${name} ${Python3_LIBRARIES} pybind11::embed xtensor )
131
+ endfunction ()
132
+
133
+ if (${ADD_DEMO} )
134
+ find_package (
135
+ Python3
136
+ COMPONENTS NumPy
137
+ REQUIRED )
138
+ find_package (xtensor 0.24.0 REQUIRED )
139
+ set (CMAKE_CXX_STANDARD 17 )
140
+ set (CMAKE_CXX_FLAGS
141
+ "-Wall -g -DUSE_GUI=${USE_GUI} -DMATPLOTLIB_MINOR_VER_GTE_4=${MATPLOTLIB_MINOR_VER_GTE_4} "
142
+ )
143
+ add_subdirectory (gallery/tests )
144
+ add_subdirectory (gallery/lines_bars_and_markers )
145
+ add_subdirectory (gallery/subplots_axes_and_figures )
146
+ add_subdirectory (gallery/statistics )
147
+ add_subdirectory (gallery/images_contours_and_fields )
148
+ add_subdirectory (gallery/shapes_and_collections )
149
+ add_subdirectory (gallery/artist_animation )
150
+ add_subdirectory (gallery/mplot3d )
151
+ add_subdirectory (gallery/scales )
152
+ endif ()
0 commit comments