Skip to content

Commit 61da78f

Browse files
author
Ilya Makarov
committed
Updated cmake readme section.
1 parent d687405 commit 61da78f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ matplotlib-cpp.
211211

212212
If you prefer to use CMake as build system, you will want to add something like this to your
213213
CMakeLists.txt:
214+
215+
**Recommended way(since CMake 3.12):**
216+
217+
It's easy to use cmake official [docs](https://cmake.org/cmake/help/git-stage/module/FindPython2.html#module:FindPython2) to find Python 2(or 3) interpreter, compiler and development environment (include directories and libraries).
218+
219+
NumPy is optional here, delete it from cmake script, if you don't need it.
220+
221+
```cmake
222+
find_package(Python2 COMPONENTS Development NumPy)
223+
target_include_directories(myproject PRIVATE ${Python2_INCLUDE_DIRS} ${Python2_NumPy_INCLUDE_DIRS})
224+
target_link_libraries(myproject Python2::Python Python2::NumPy)
225+
```
226+
227+
**Legacy way(unrecommended):**
228+
214229
```cmake
215230
find_package(PythonLibs 2.7)
216231
target_include_directories(myproject PRIVATE ${PYTHON_INCLUDE_DIRS})

0 commit comments

Comments
 (0)