Skip to content

Added CMake support for library #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.0)

find_package(PythonLibs REQUIRED)

add_library(matplotlibcpp INTERFACE)
target_include_directories(matplotlibcpp INTERFACE include)
target_include_directories(matplotlibcpp INTERFACE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(matplotlibcpp INTERFACE ${PYTHON_LIBRARIES})

option(MATPLOTLIBCPP_EXAMPLES "Build matplotlib examples" OFF)

if(MATPLOTLIBCPP_EXAMPLES)
set (CMAKE_CXX_STANDARD 11)

add_executable(minimal "examples/minimal.cpp")
target_link_libraries(minimal matplotlibcpp)
target_compile_definitions(minimal PRIVATE "-DWITHOUT_NUMPY")

add_executable(basic "examples/basic.cpp")
target_link_libraries(basic matplotlibcpp)

add_executable(modern "examples/modern.cpp")
target_link_libraries(modern matplotlibcpp)

add_executable(animation "examples/animation.cpp")
target_link_libraries(animation matplotlibcpp)

add_executable(nonblock "examples/nonblock.cpp")
target_link_libraries(nonblock matplotlibcpp)

add_executable(xkcd "examples/xkcd.cpp")
target_link_libraries(xkcd matplotlibcpp)

endif(MATPLOTLIBCPP_EXAMPLES)
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
examples: minimal basic modern animation nonblock xkcd

minimal: examples/minimal.cpp matplotlibcpp.h
cd examples && g++ -DWITHOUT_NUMPY minimal.cpp -I/usr/include/python2.7 -lpython2.7 -o minimal -std=c++11
minimal: examples/minimal.cpp ./include/matplotlibcpp.h
cd examples && g++ -DWITHOUT_NUMPY minimal.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o minimal -std=c++11

basic: examples/basic.cpp matplotlibcpp.h
cd examples && g++ basic.cpp -I/usr/include/python2.7 -lpython2.7 -o basic
basic: examples/basic.cpp ./include/matplotlibcpp.h
cd examples && g++ basic.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o basic

modern: examples/modern.cpp matplotlibcpp.h
cd examples && g++ modern.cpp -I/usr/include/python2.7 -lpython2.7 -o modern -std=c++11
modern: examples/modern.cpp ./include/matplotlibcpp.h
cd examples && g++ modern.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o modern -std=c++11

animation: examples/animation.cpp matplotlibcpp.h
cd examples && g++ animation.cpp -I/usr/include/python2.7 -lpython2.7 -o animation -std=c++11
animation: examples/animation.cpp ./include/matplotlibcpp.h
cd examples && g++ animation.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o animation -std=c++11

nonblock: examples/nonblock.cpp matplotlibcpp.h
cd examples && g++ nonblock.cpp -I/usr/include/python2.7 -lpython2.7 -o nonblock -std=c++11
nonblock: examples/nonblock.cpp ./include/matplotlibcpp.h
cd examples && g++ nonblock.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o nonblock -std=c++11

xkcd: examples/xkcd.cpp matplotlibcpp.h
cd examples && g++ xkcd.cpp -I/usr/include/python2.7 -lpython2.7 -o xkcd -std=c++11
xkcd: examples/xkcd.cpp ./include/matplotlibcpp.h
cd examples && g++ xkcd.cpp -I../include -I/usr/include/python2.7 -lpython2.7 -o xkcd -std=c++11

clean:
rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd}
Binary file added examples/animation
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/animation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"

namespace plt = matplotlibcpp;

Expand Down
Binary file added examples/basic
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/basic.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"

namespace plt = matplotlibcpp;

Expand Down
Binary file added examples/minimal
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/minimal.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"

namespace plt = matplotlibcpp;

Expand Down
Binary file added examples/modern
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/modern.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"

using namespace std;
namespace plt = matplotlibcpp;
Expand Down
Binary file added examples/nonblock
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/nonblock.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"

namespace plt = matplotlibcpp;

Expand Down
Binary file added examples/xkcd
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/xkcd.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../matplotlibcpp.h"
#include "matplotlibcpp.h"
#include <vector>
#include <cmath>

Expand Down
File renamed without changes.