From c4fb836ec60e94a7f3bf8b085bfff37a44dcc0a7 Mon Sep 17 00:00:00 2001 From: KevinLADLee Date: Fri, 15 Jun 2018 11:11:29 +0800 Subject: [PATCH] Add a simple cmake example --- CMakeLists.txt | 16 ++++++++++++++++ modern.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 modern.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e92b7a1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +project(matplotlib_cpp) +cmake_minimum_required(VERSION 3.1) +set(CMAKE_CXX_STANDARD 14) +set(PYTHON_LIBRARY /usr/lib/x86_64-linux-gnu/libpython2.7.so) +set(PYTHON_INCLUDE_DIR /usr/include/python2.7) +find_package(PythonLibs 2.7 REQUIRED) + +include_directories(${PYTHON_INCLUDE_DIRS}) + +add_executable(modern modern.cpp matplotlibcpp.h) + +message(${PYTHON_LIBRARIES}) +target_link_libraries( +modern +${PYTHON_LIBRARIES} +) diff --git a/modern.cpp b/modern.cpp new file mode 100644 index 0000000..4080fd6 --- /dev/null +++ b/modern.cpp @@ -0,0 +1,26 @@ +#include +#include "matplotlibcpp.h" + +using namespace std; +namespace plt = matplotlibcpp; + +int main() +{ + // Prepare data. + int n = 5000; // number of data points + vector x(n),y(n); + for(int i=0; i