diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a1c20739 --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile b/Makefile index e75d1343..ee95dbc5 100644 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/examples/animation b/examples/animation new file mode 100755 index 00000000..c4b2e277 Binary files /dev/null and b/examples/animation differ diff --git a/examples/animation.cpp b/examples/animation.cpp index d9794300..543534b0 100644 --- a/examples/animation.cpp +++ b/examples/animation.cpp @@ -1,6 +1,6 @@ #define _USE_MATH_DEFINES #include -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" namespace plt = matplotlibcpp; diff --git a/examples/basic b/examples/basic new file mode 100755 index 00000000..542b8c57 Binary files /dev/null and b/examples/basic differ diff --git a/examples/basic.cpp b/examples/basic.cpp index 2b02f27b..ddfaf650 100644 --- a/examples/basic.cpp +++ b/examples/basic.cpp @@ -1,7 +1,7 @@ #define _USE_MATH_DEFINES #include #include -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" namespace plt = matplotlibcpp; diff --git a/examples/minimal b/examples/minimal new file mode 100755 index 00000000..6cfafb0a Binary files /dev/null and b/examples/minimal differ diff --git a/examples/minimal.cpp b/examples/minimal.cpp index fbe1e1cd..2ad6f06d 100644 --- a/examples/minimal.cpp +++ b/examples/minimal.cpp @@ -1,4 +1,4 @@ -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" namespace plt = matplotlibcpp; diff --git a/examples/modern b/examples/modern new file mode 100755 index 00000000..c40ce25a Binary files /dev/null and b/examples/modern differ diff --git a/examples/modern.cpp b/examples/modern.cpp index a8aa0c75..e85978df 100644 --- a/examples/modern.cpp +++ b/examples/modern.cpp @@ -1,6 +1,6 @@ #define _USE_MATH_DEFINES #include -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" using namespace std; namespace plt = matplotlibcpp; diff --git a/examples/nonblock b/examples/nonblock new file mode 100755 index 00000000..e827c2bd Binary files /dev/null and b/examples/nonblock differ diff --git a/examples/nonblock.cpp b/examples/nonblock.cpp index 327d96c7..7396fc3c 100644 --- a/examples/nonblock.cpp +++ b/examples/nonblock.cpp @@ -1,6 +1,6 @@ #define _USE_MATH_DEFINES #include -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" namespace plt = matplotlibcpp; diff --git a/examples/xkcd b/examples/xkcd new file mode 100755 index 00000000..abc761d6 Binary files /dev/null and b/examples/xkcd differ diff --git a/examples/xkcd.cpp b/examples/xkcd.cpp index 9bf64548..5dea705d 100644 --- a/examples/xkcd.cpp +++ b/examples/xkcd.cpp @@ -1,4 +1,4 @@ -#include "../matplotlibcpp.h" +#include "matplotlibcpp.h" #include #include diff --git a/matplotlibcpp.h b/include/matplotlibcpp.h similarity index 100% rename from matplotlibcpp.h rename to include/matplotlibcpp.h