|
1 | | -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_11 |
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 | | - |
39 | | -# Examples |
40 | | -add_executable(minimal examples/minimal.cpp) |
41 | | -target_link_libraries(minimal PRIVATE matplotlib_cpp) |
42 | | -set_target_properties(minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
43 | | - |
44 | | -add_executable(basic examples/basic.cpp) |
45 | | -target_link_libraries(basic PRIVATE matplotlib_cpp) |
46 | | -set_target_properties(basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
47 | | - |
48 | | -add_executable(modern examples/modern.cpp) |
49 | | -target_link_libraries(modern PRIVATE matplotlib_cpp) |
50 | | -set_target_properties(modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
51 | | - |
52 | | -add_executable(animation examples/animation.cpp) |
53 | | -target_link_libraries(animation PRIVATE matplotlib_cpp) |
54 | | -set_target_properties(animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
55 | | - |
56 | | -add_executable(nonblock examples/nonblock.cpp) |
57 | | -target_link_libraries(nonblock PRIVATE matplotlib_cpp) |
58 | | -set_target_properties(nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
59 | | - |
60 | | -add_executable(xkcd examples/xkcd.cpp) |
61 | | -target_link_libraries(xkcd PRIVATE matplotlib_cpp) |
62 | | -set_target_properties(xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
63 | | - |
64 | | -add_executable(bar examples/bar.cpp) |
65 | | -target_link_libraries(bar PRIVATE matplotlib_cpp) |
66 | | -set_target_properties(bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
67 | | - |
68 | | -add_executable(fill_inbetween examples/fill_inbetween.cpp) |
69 | | -target_link_libraries(fill_inbetween PRIVATE matplotlib_cpp) |
70 | | -set_target_properties(fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
71 | | - |
72 | | -add_executable(fill examples/fill.cpp) |
73 | | -target_link_libraries(fill PRIVATE matplotlib_cpp) |
74 | | -set_target_properties(fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
75 | | - |
76 | | -add_executable(update examples/update.cpp) |
77 | | -target_link_libraries(update PRIVATE matplotlib_cpp) |
78 | | -set_target_properties(update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
79 | | - |
80 | | -add_executable(subplot2grid examples/subplot2grid.cpp) |
81 | | -target_link_libraries(subplot2grid PRIVATE matplotlib_cpp) |
82 | | -set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
83 | | - |
84 | | -add_executable(lines3d examples/lines3d.cpp) |
85 | | -target_link_libraries(lines3d PRIVATE matplotlib_cpp) |
86 | | -set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
87 | | - |
88 | | -if(Python3_NumPy_FOUND) |
89 | | - add_executable(surface examples/surface.cpp) |
90 | | - target_link_libraries(surface PRIVATE matplotlib_cpp) |
91 | | - set_target_properties(surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
92 | | - |
93 | | - add_executable(colorbar examples/colorbar.cpp) |
94 | | - target_link_libraries(colorbar PRIVATE matplotlib_cpp) |
95 | | - set_target_properties(colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
96 | | - add_executable(contour examples/contour.cpp) |
97 | | - target_link_libraries(contour PRIVATE matplotlib_cpp) |
98 | | - set_target_properties(contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
99 | | - |
100 | | - add_executable(spy examples/spy.cpp) |
101 | | - target_link_libraries(spy PRIVATE matplotlib_cpp) |
102 | | - set_target_properties(spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
103 | | -endif() |
104 | | - |
105 | | - |
106 | | -# Install headers |
107 | | -install(FILES |
108 | | - "${PROJECT_SOURCE_DIR}/matplotlibcpp.h" |
109 | | - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
110 | | - |
111 | | - |
112 | | -# Install targets file |
113 | | -install(EXPORT install_targets |
114 | | - FILE |
115 | | - ${PACKAGE_NAME}Targets.cmake |
116 | | - NAMESPACE |
117 | | - ${PACKAGE_NAME}:: |
118 | | - DESTINATION |
119 | | - ${INSTALL_CONFIGDIR} |
120 | | -) |
121 | | - |
122 | | - |
123 | | -# Install matplotlib_cppConfig.cmake |
124 | | -include(CMakePackageConfigHelpers) |
125 | | -configure_package_config_file( |
126 | | - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PACKAGE_NAME}Config.cmake.in |
127 | | - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake |
128 | | - INSTALL_DESTINATION ${INSTALL_CONFIGDIR} |
129 | | -) |
130 | | -install(FILES |
131 | | - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake |
132 | | - DESTINATION ${INSTALL_CONFIGDIR} |
133 | | -) |
| 1 | +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_11 |
| 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 | + |
| 39 | +# Examples |
| 40 | +add_executable(minimal examples/minimal.cpp) |
| 41 | +target_link_libraries(minimal PRIVATE matplotlib_cpp) |
| 42 | +set_target_properties(minimal PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 43 | + |
| 44 | +add_executable(basic examples/basic.cpp) |
| 45 | +target_link_libraries(basic PRIVATE matplotlib_cpp) |
| 46 | +set_target_properties(basic PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 47 | + |
| 48 | +add_executable(modern examples/modern.cpp) |
| 49 | +target_link_libraries(modern PRIVATE matplotlib_cpp) |
| 50 | +set_target_properties(modern PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 51 | + |
| 52 | +add_executable(animation examples/animation.cpp) |
| 53 | +target_link_libraries(animation PRIVATE matplotlib_cpp) |
| 54 | +set_target_properties(animation PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 55 | + |
| 56 | +add_executable(nonblock examples/nonblock.cpp) |
| 57 | +target_link_libraries(nonblock PRIVATE matplotlib_cpp) |
| 58 | +set_target_properties(nonblock PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 59 | + |
| 60 | +add_executable(xkcd examples/xkcd.cpp) |
| 61 | +target_link_libraries(xkcd PRIVATE matplotlib_cpp) |
| 62 | +set_target_properties(xkcd PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 63 | + |
| 64 | +add_executable(bar examples/bar.cpp) |
| 65 | +target_link_libraries(bar PRIVATE matplotlib_cpp) |
| 66 | +set_target_properties(bar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 67 | + |
| 68 | +add_executable(fill_inbetween examples/fill_inbetween.cpp) |
| 69 | +target_link_libraries(fill_inbetween PRIVATE matplotlib_cpp) |
| 70 | +set_target_properties(fill_inbetween PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 71 | + |
| 72 | +add_executable(fill examples/fill.cpp) |
| 73 | +target_link_libraries(fill PRIVATE matplotlib_cpp) |
| 74 | +set_target_properties(fill PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 75 | + |
| 76 | +add_executable(update examples/update.cpp) |
| 77 | +target_link_libraries(update PRIVATE matplotlib_cpp) |
| 78 | +set_target_properties(update PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 79 | + |
| 80 | +add_executable(subplot2grid examples/subplot2grid.cpp) |
| 81 | +target_link_libraries(subplot2grid PRIVATE matplotlib_cpp) |
| 82 | +set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 83 | + |
| 84 | +add_executable(lines3d examples/lines3d.cpp) |
| 85 | +target_link_libraries(lines3d PRIVATE matplotlib_cpp) |
| 86 | +set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 87 | + |
| 88 | +if(Python3_NumPy_FOUND) |
| 89 | + add_executable(surface examples/surface.cpp) |
| 90 | + target_link_libraries(surface PRIVATE matplotlib_cpp) |
| 91 | + set_target_properties(surface PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 92 | + |
| 93 | + add_executable(colorbar examples/colorbar.cpp) |
| 94 | + target_link_libraries(colorbar PRIVATE matplotlib_cpp) |
| 95 | + set_target_properties(colorbar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 96 | + add_executable(contour examples/contour.cpp) |
| 97 | + target_link_libraries(contour PRIVATE matplotlib_cpp) |
| 98 | + set_target_properties(contour PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 99 | + |
| 100 | + add_executable(spy examples/spy.cpp) |
| 101 | + target_link_libraries(spy PRIVATE matplotlib_cpp) |
| 102 | + set_target_properties(spy PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") |
| 103 | +endif() |
| 104 | + |
| 105 | + |
| 106 | +# Install headers |
| 107 | +install(FILES |
| 108 | + "${PROJECT_SOURCE_DIR}/matplotlibcpp.h" |
| 109 | + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 110 | + |
| 111 | + |
| 112 | +# Install targets file |
| 113 | +install(EXPORT install_targets |
| 114 | + FILE |
| 115 | + ${PACKAGE_NAME}Targets.cmake |
| 116 | + NAMESPACE |
| 117 | + ${PACKAGE_NAME}:: |
| 118 | + DESTINATION |
| 119 | + ${INSTALL_CONFIGDIR} |
| 120 | +) |
| 121 | + |
| 122 | + |
| 123 | +# Install matplotlib_cppConfig.cmake |
| 124 | +include(CMakePackageConfigHelpers) |
| 125 | +configure_package_config_file( |
| 126 | + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PACKAGE_NAME}Config.cmake.in |
| 127 | + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake |
| 128 | + INSTALL_DESTINATION ${INSTALL_CONFIGDIR} |
| 129 | +) |
| 130 | +install(FILES |
| 131 | + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake |
| 132 | + DESTINATION ${INSTALL_CONFIGDIR} |
| 133 | +) |
0 commit comments