Skip to content
Snippets Groups Projects
Commit ee6aca6a authored by soblin's avatar soblin
Browse files

updated CMakeLists.txt

parent 929779b0
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ project(
)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 REQUIRED)
find_package(pybind11 2.4.3 REQUIRED)
set(matplotlibcpp17_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
......@@ -25,9 +25,8 @@ function(add_demo name path)
target_include_directories(${name} PUBLIC
${Python3_INCLUDE_DIRS}
${matplotlibcpp17_INCLUDE_DIRS}
${xtensor_INCLUDE_DIRS}
)
target_link_libraries(${name} ${Python3_LIBRARIES} pybind11::embed)
target_link_libraries(${name} ${Python3_LIBRARIES} pybind11::embed xtensor)
endfunction()
if(${ADD_DEMO})
......
......
......@@ -29,6 +29,12 @@ $ (make uninstall)
For using matplotlibcpp17 from CMakeLists.txt, see [hello_world](https://github.com/soblin/matplotlibcpp17/tree/master/hello_world) example.
```bash
find_package(matplotlibcpp17)
...
target_link_libraries(a.out matplotlibcpp17::matplotlibcpp17)
```
Or you could just add include path to `include` directory and compile your codes as descibed in [minimal example](#minimal-example).
## Syntax
......
......
......@@ -3,8 +3,8 @@ add_library(test_shared_lib SHARED
test_lib.cpp
)
target_compile_options(test_shared_lib PUBLIC "-fPIC")
target_include_directories(test_shared_lib PUBLIC ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
target_link_libraries(test_shared_lib ${PYTHON_LIBRARY} pybind11::embed)
target_include_directories(test_shared_lib PUBLIC ${Python3_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
target_link_libraries(test_shared_lib ${Python3_LIBRARIES} pybind11::embed)
# link it
add_executable(test_lib_main test_lib_main.cpp)
target_link_libraries(test_lib_main ${PYTHON_LIBRARY} pybind11::embed test_shared_lib)
target_link_libraries(test_lib_main test_shared_lib)
......@@ -3,8 +3,8 @@ add_library(test_static_lib STATIC
test_lib.cpp
)
target_compile_options(test_static_lib PUBLIC "-fPIC")
target_include_directories(test_static_lib PUBLIC ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
target_link_libraries(test_static_lib ${PYTHON_LIBRARY} pybind11::embed)
target_include_directories(test_static_lib PUBLIC ${Python3_INCLUDE_DIRS} ${matplotlibcpp17_INCLUDE_DIRS})
target_link_libraries(test_static_lib ${Python3_LIBRARIES} pybind11::embed)
# link it
add_executable(test_lib_static_main test_lib_main.cpp)
target_link_libraries(test_lib_static_main ${PYTHON_LIBRARY} pybind11::embed test_static_lib)
target_link_libraries(test_lib_static_main test_static_lib)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment