Skip to content

Commit b89823a

Browse files
committed
Add src-include/CMakeList.txt
1 parent 2d9e537 commit b89823a

32 files changed

+85
-113
lines changed

CMakeLists.txt

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
1-
project(MatplotlibC++)
2-
cmake_minimum_required(VERSION 2.8)
3-
4-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
5-
6-
find_package(Eigen3)
7-
8-
if (${EIGEN3_FOUND})
9-
include_directories(${EIGEN3_INCLUDE_DIR})
10-
else()
11-
message(STATUS "Eigen3 not found")
1+
# Disable in-source builds to prevent source tree corruption.
2+
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
3+
message(FATAL_ERROR "
4+
FATAL: In-source builds are not allowed.
5+
You should create a separate directory for build files.")
126
endif()
137

14-
find_package(Python3 COMPONENTS Interpreter Development)
15-
if (${Python3_FOUND})
16-
include_directories(${Python3_INCLUDE_DIRS})
17-
else()
18-
message(FATAL_ERROR "Python3 not found, please install it.")
19-
endif()
8+
set(PROJECT_NAME "MatplotlibCpp")
9+
set(AUTHOR "Luca Macchiusi <[email protected]>")
10+
set(PROJECT_URL "https://github.com/LucaMac1/matplotlib-cpp")
2011

21-
find_package(NumPy)
22-
if (${PYTHON_NUMPY_FOUND})
23-
include_directories(${PYTHON_NUMPY_INCLUDE_DIR})
24-
else()
25-
message(WARNING "Python3 NumPy not found, proceeding with -DWITHOUT_NUMPY."
26-
" Some functions might not work.")
27-
add_definitions(-DWITHOUT_NUMPY)
28-
endif()
12+
cmake_minimum_required(VERSION 3.12...3.17)
13+
project(${PROJECT_NAME} VERSION 1.0 LANGUAGES CXX)
14+
15+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
2916

30-
add_subdirectory(examples)
17+
add_subdirectory(include)
18+
add_subdirectory(src)

Makefile

Lines changed: 0 additions & 57 deletions
This file was deleted.

examples/animation.gif

-32.5 KB
Binary file not shown.

include/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.12...3.17)
2+
project("matplotlibcpplib")
3+
4+
set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/matplotlibcpp.h)
5+
#add_library(${PROJECT_NAME} INTERFACE)
6+
add_library(${PROJECT_NAME} STATIC ${HEADER_FILES})
7+
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
8+
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON)
9+
10+
#find_package(Eigen3 REQUIRED)
11+
12+
#if (${EIGEN3_FOUND})
13+
#target_include_directories(${PROJECT_NAME} PRIVATE ${EIGEN3_INCLUDE_DIR})
14+
#target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen)
15+
#else()
16+
#message(STATUS "Eigen3 not found")
17+
#endif()
18+
19+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
20+
if (${Python_FOUND})
21+
target_include_directories(${PROJECT_NAME} PRIVATE ${Python_INCLUDE_DIRS})
22+
target_link_libraries(${PROJECT_NAME} PUBLIC Python::Python)
23+
else()
24+
message(FATAL_ERROR "Python not found, please install it.")
25+
endif()
26+
27+
find_package(Python REQUIRED COMPONENTS NumPy)
28+
if (${Python_NumPy_FOUND})
29+
target_include_directories(${PROJECT_NAME} PRIVATE ${Python_NumPy_INCLUDE_DIRS})
30+
target_link_libraries(${PROJECT_NAME} PUBLIC Python::NumPy)
31+
else()
32+
message(WARNING "Python NumPy not found, proceeding with -DWITHOUT_NUMPY."
33+
" Some functions might not work.")
34+
add_definitions(-DWITHOUT_NUMPY)
35+
endif()
36+
37+
# message(STATUS "EIGEN INCLUDE_DIRS: " ${EIGEN3_INCLUDE_DIR})
38+
message(STATUS "Python INCLUDE DIRS: " ${Python_INCLUDE_DIRS})
39+
message(STATUS "NumPy INCLUDE DIRS: " ${Python_NumPy_INCLUDE_DIRS})
File renamed without changes.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ function(add_example basename)
33
set(CMAKE_CXX_STANDARD 17)
44

55
# add WITH_EIGEN, if specified
6-
if(WITH_EIGEN)
7-
add_definitions("-DWITH_EIGEN")
8-
endif()
6+
#if(WITH_EIGEN)
7+
# add_definitions("-DWITH_EIGEN")
8+
#endif()
99

1010
# add the exectuable and link it to the Python libs
11-
add_executable(${basename} ${basename}.cpp ../matplotlibcpp.h)
12-
target_link_libraries(${basename} ${Python3_LIBRARIES})
11+
# add_executable(${basename} ${basename}.cpp ../matplotlibcpp.h)
12+
# target_link_libraries(${basename} ${Python3_LIBRARIES})
13+
add_executable(${basename} ${basename}.cpp)
14+
target_link_libraries(${basename} matplotlibcpplib)
1315
endfunction(add_example)
1416

1517
# add the executables
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define _USE_MATH_DEFINES
2-
#include "../matplotlibcpp.h"
2+
#include "matplotlibcpp.h"
33
#include <cmath>
44

55
namespace plt = matplotlibcpp;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../matplotlibcpp.h"
1+
#include "matplotlibcpp.h"
22
namespace plt = matplotlibcpp;
33

44
void horizontal() {

examples/bar.cpp renamed to src/bar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <iostream>
44
#include <string>
5-
#include "../matplotlibcpp.h"
5+
#include "matplotlibcpp.h"
66
namespace plt = matplotlibcpp;
77

88
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)