1
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_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 ()
0 commit comments