Skip to content

Commit 1deaac8

Browse files
committed
Header moved to include folder. Examples removed.
1 parent f7a0ca9 commit 1deaac8

33 files changed

+40
-702
lines changed

CMakeLists.txt

+40-94
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,29 @@ project(matplotlib_cpp LANGUAGES CXX)
33

44
include(GNUInstallDirs)
55
set(PACKAGE_NAME matplotlib_cpp)
6-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${PACKAGE_NAME}/cmake)
76
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()
819

920
# Library target
1021
add_library(matplotlib_cpp INTERFACE)
1122
target_include_directories(matplotlib_cpp
1223
INTERFACE
13-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/examples>
24+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
1425
$<INSTALL_INTERFACE:include>
1526
)
16-
target_compile_features(matplotlib_cpp INTERFACE
17-
cxx_std_17
18-
)
27+
target_compile_features(matplotlib_cpp INTERFACE cxx_std_17)
28+
1929
# TODO: Use `Development.Embed` component when requiring cmake >= 3.18
2030
if(USING_PYTHON3)
2131
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
@@ -48,106 +58,42 @@ else()
4858
endif()
4959

5060

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})
13061

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+
)
13168

13269
# 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
14073
)
14174

142-
14375
# Install matplotlib_cppConfig.cmake
14476
include(CMakePackageConfigHelpers)
14577
configure_package_config_file(
14678
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PACKAGE_NAME}Config.cmake.in
14779
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}Config.cmake
148-
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
80+
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}/cmake/matplotlib_cpp
14981
)
82+
15083
install(FILES
15184
${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}
15394
)
95+
96+
97+
98+
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
99+
export(PACKAGE matplotlib_cpp)

examples/.gitignore

-14
This file was deleted.

examples/animation.cpp

-36
This file was deleted.

examples/animation.gif

-32.5 KB
Binary file not shown.

examples/bar.cpp

-18
This file was deleted.

examples/bar.png

-11.7 KB
Binary file not shown.

examples/basic.cpp

-44
This file was deleted.

examples/basic.png

-36.5 KB
Binary file not shown.

examples/colorbar.cpp

-32
This file was deleted.

examples/contour.cpp

-24
This file was deleted.

examples/fill.cpp

-35
This file was deleted.

examples/fill.png

-61.5 KB
Binary file not shown.

examples/fill_between.png

-24.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)