diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..75d40b17 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.0) +project(matplotlibcpp CXX) + +include(GNUInstallDirs) + +find_package(PythonLibs 2.7 REQUIRED) + +add_library(matplotlibcpp INTERFACE) + +target_include_directories(matplotlibcpp + INTERFACE + ${PYTHON_INCLUDE_DIRS} + $ + $) + +target_link_libraries(matplotlibcpp INTERFACE ${PYTHON_LIBRARIES}) + +# 'make install' to the correct locations (provided by GNUInstallDirs). +install(TARGETS matplotlibcpp EXPORT matplotlibcpp-config + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES matplotlibcpp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(EXPORT matplotlibcpp-config DESTINATION cmake) + +# Makes the project importable from the build directory +export(TARGETS matplotlibcpp FILE matplotlibcpp-config.cmake) diff --git a/matplotlibcpp.h b/matplotlibcpp.h index ca81460a..bc0d13bc 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -407,11 +407,10 @@ namespace matplotlibcpp { PyObject* yerrarray = get_array(yerr); PyObject *kwargs = PyDict_New(); + PyDict_SetItemString(kwargs, "fmt", PyString_FromString(s.c_str())); PyDict_SetItemString(kwargs, "yerr", yerrarray); - PyObject *pystring = PyString_FromString(s.c_str()); - PyObject *plot_args = PyTuple_New(2); PyTuple_SetItem(plot_args, 0, xarray); PyTuple_SetItem(plot_args, 1, yarray);