@@ -3,19 +3,29 @@ project(matplotlib_cpp LANGUAGES CXX)
3
3
4
4
include (GNUInstallDirs)
5
5
set (PACKAGE_NAME matplotlib_cpp)
6
- set (INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR} /${PACKAGE_NAME} /cmake)
7
6
set (USING_PYTHON3 True )
7
+ set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR} /lib)
8
+ set (INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries" )
9
+ set (INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables" )
10
+ set (INSTALL_INCLUDE_DIR include CACHE PATH
11
+ "Installation directory for header files" )
12
+
13
+ foreach (p LIB BIN INCLUDE CMAKE)
14
+ set (var INSTALL_${p} _DIR)
15
+ if (NOT IS_ABSOLUTE "${${var} }" )
16
+ set (${var} "${CMAKE_INSTALL_PREFIX} /${${var} }" )
17
+ endif ()
18
+ endforeach ()
8
19
9
20
# Library target
10
21
add_library (matplotlib_cpp INTERFACE )
11
22
target_include_directories (matplotlib_cpp
12
23
INTERFACE
13
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /examples >
24
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} / include >
14
25
$<INSTALL_INTERFACE:include >
15
26
)
16
- target_compile_features (matplotlib_cpp INTERFACE
17
- cxx_std_17
18
- )
27
+ target_compile_features (matplotlib_cpp INTERFACE cxx_std_17)
28
+
19
29
# TODO: Use `Development.Embed` component when requiring cmake >= 3.18
20
30
if (USING_PYTHON3)
21
31
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
@@ -48,106 +58,42 @@ else()
48
58
endif ()
49
59
50
60
51
- install (
52
- TARGETS matplotlib_cpp
53
- EXPORT install_targets
54
- )
55
-
56
- export (PACKAGE matplotlib_cpp)
57
-
58
-
59
- # Examples
60
- add_executable (minimal examples/minimal.cpp)
61
- target_link_libraries (minimal PRIVATE matplotlib_cpp)
62
- set_target_properties (minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
63
-
64
- add_executable (basic examples/basic.cpp)
65
- target_link_libraries (basic PRIVATE matplotlib_cpp)
66
- set_target_properties (basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
67
-
68
- add_executable (modern examples/modern.cpp)
69
- target_link_libraries (modern PRIVATE matplotlib_cpp)
70
- set_target_properties (modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
71
-
72
- add_executable (animation examples/animation.cpp)
73
- target_link_libraries (animation PRIVATE matplotlib_cpp)
74
- set_target_properties (animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
75
-
76
- add_executable (nonblock examples/nonblock.cpp)
77
- target_link_libraries (nonblock PRIVATE matplotlib_cpp)
78
- set_target_properties (nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
79
-
80
- add_executable (xkcd examples/xkcd.cpp)
81
- target_link_libraries (xkcd PRIVATE matplotlib_cpp)
82
- set_target_properties (xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
83
-
84
- add_executable (bar examples/bar.cpp)
85
- target_link_libraries (bar PRIVATE matplotlib_cpp)
86
- set_target_properties (bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
87
-
88
- add_executable (fill_inbetween examples/fill_inbetween.cpp)
89
- target_link_libraries (fill_inbetween PRIVATE matplotlib_cpp)
90
- set_target_properties (fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
91
-
92
- add_executable (fill examples/fill.cpp)
93
- target_link_libraries (fill PRIVATE matplotlib_cpp)
94
- set_target_properties (fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
95
-
96
- add_executable (update examples/update.cpp)
97
- target_link_libraries (update PRIVATE matplotlib_cpp)
98
- set_target_properties (update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
99
-
100
- add_executable (subplot2grid examples/subplot2grid.cpp)
101
- target_link_libraries (subplot2grid PRIVATE matplotlib_cpp)
102
- set_target_properties (subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
103
-
104
- add_executable (lines3d examples/lines3d.cpp)
105
- target_link_libraries (lines3d PRIVATE matplotlib_cpp)
106
- set_target_properties (lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
107
-
108
- if (Python3_NumPy_FOUND)
109
- add_executable (surface examples/surface.cpp)
110
- target_link_libraries (surface PRIVATE matplotlib_cpp)
111
- set_target_properties (surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
112
-
113
- add_executable (colorbar examples/colorbar.cpp)
114
- target_link_libraries (colorbar PRIVATE matplotlib_cpp)
115
- set_target_properties (colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
116
- add_executable (contour examples/contour.cpp)
117
- target_link_libraries (contour PRIVATE matplotlib_cpp)
118
- set_target_properties (contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
119
-
120
- add_executable (spy examples/spy.cpp)
121
- target_link_libraries (spy PRIVATE matplotlib_cpp)
122
- set_target_properties (spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
123
- endif ()
124
-
125
-
126
- # Install headers
127
- install (FILES
128
- "${PROJECT_SOURCE_DIR} /matplotlibcpp.h"
129
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
130
61
62
+ install (TARGETS matplotlib_cpp
63
+ EXPORT matplotlib_cpp-targets
64
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
65
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
66
+ PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR} /matplotlib_cpp"
67
+ )
131
68
132
69
# Install targets file
133
- install (EXPORT install_targets
134
- FILE
135
- ${PACKAGE_NAME} Targets.cmake
136
- NAMESPACE
137
- ${PACKAGE_NAME} ::
138
- DESTINATION
139
- ${INSTALL_CONFIGDIR}
70
+ install (EXPORT matplotlib_cpp-targets
71
+ FILE ${PACKAGE_NAME} Targets.cmake
72
+ DESTINATION ${INSTALL_CMAKE_DIR} /cmake/matplotlib_cpp
140
73
)
141
74
142
-
143
75
# Install matplotlib_cppConfig.cmake
144
76
include (CMakePackageConfigHelpers)
145
77
configure_package_config_file(
146
78
${CMAKE_CURRENT_SOURCE_DIR} /cmake/${PACKAGE_NAME} Config.cmake.in
147
79
${CMAKE_CURRENT_BINARY_DIR} /${PACKAGE_NAME} Config.cmake
148
- INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
80
+ INSTALL_DESTINATION ${INSTALL_CMAKE_DIR} /cmake/matplotlib_cpp
149
81
)
82
+
150
83
install (FILES
151
84
${CMAKE_CURRENT_BINARY_DIR} /${PACKAGE_NAME} Config.cmake
152
- DESTINATION ${INSTALL_CONFIGDIR}
85
+ DESTINATION ${INSTALL_CMAKE_DIR} /cmake/matplotlib_cpp
86
+ )
87
+
88
+ export (TARGETS matplotlib_cpp
89
+ FILE ${PACKAGE_NAME} Config.cmake)
90
+
91
+ # Install headers
92
+ install (FILES "${${CMAKE_INSTALL_LIBDIR} }/matplotlibcpp.h"
93
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
153
94
)
95
+
96
+
97
+
98
+ set (CMAKE_EXPORT_PACKAGE_REGISTRY ON )
99
+ export (PACKAGE matplotlib_cpp)
0 commit comments