Skip to content

Commit ee6aca6

Browse files
committed
updated CMakeLists.txt
1 parent 929779b commit ee6aca6

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
)
99

1010
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
11-
find_package(pybind11 REQUIRED)
11+
find_package(pybind11 2.4.3 REQUIRED)
1212

1313
set(matplotlibcpp17_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
1414

@@ -25,9 +25,8 @@ function(add_demo name path)
2525
target_include_directories(${name} PUBLIC
2626
${Python3_INCLUDE_DIRS}
2727
${matplotlibcpp17_INCLUDE_DIRS}
28-
${xtensor_INCLUDE_DIRS}
2928
)
30-
target_link_libraries(${name} ${Python3_LIBRARIES} pybind11::embed)
29+
target_link_libraries(${name} ${Python3_LIBRARIES} pybind11::embed xtensor)
3130
endfunction()
3231

3332
if(${ADD_DEMO})

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ $ (make uninstall)
2929

3030
For using matplotlibcpp17 from CMakeLists.txt, see [hello_world](https://github.com/soblin/matplotlibcpp17/tree/master/hello_world) example.
3131

32+
```bash
33+
find_package(matplotlibcpp17)
34+
...
35+
target_link_libraries(a.out matplotlibcpp17::matplotlibcpp17)
36+
```
37+
3238
Or you could just add include path to `include` directory and compile your codes as descibed in [minimal example](#minimal-example).
3339

3440
## Syntax

tests/test_shared_lib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ add_library(test_shared_lib SHARED
33
test_lib.cpp
44
)
55
target_compile_options(test_shared_lib PUBLIC "-fPIC")
6-
target_include_directories(test_shared_lib PUBLIC ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
7-
target_link_libraries(test_shared_lib ${PYTHON_LIBRARY} pybind11::embed)
6+
target_include_directories(test_shared_lib PUBLIC ${Python3_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
7+
target_link_libraries(test_shared_lib ${Python3_LIBRARIES} pybind11::embed)
88
# link it
99
add_executable(test_lib_main test_lib_main.cpp)
10-
target_link_libraries(test_lib_main ${PYTHON_LIBRARY} pybind11::embed test_shared_lib)
10+
target_link_libraries(test_lib_main test_shared_lib)

tests/test_static_lib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ add_library(test_static_lib STATIC
33
test_lib.cpp
44
)
55
target_compile_options(test_static_lib PUBLIC "-fPIC")
6-
target_include_directories(test_static_lib PUBLIC ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
7-
target_link_libraries(test_static_lib ${PYTHON_LIBRARY} pybind11::embed)
6+
target_include_directories(test_static_lib PUBLIC ${Python3_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
7+
target_link_libraries(test_static_lib ${Python3_LIBRARIES} pybind11::embed)
88
# link it
99
add_executable(test_lib_static_main test_lib_main.cpp)
10-
target_link_libraries(test_lib_static_main ${PYTHON_LIBRARY} pybind11::embed test_static_lib)
10+
target_link_libraries(test_lib_static_main test_static_lib)

0 commit comments

Comments
 (0)