瀏覽代碼

Updated cmake readme section.

Ilya Makarov 5 年之前
父節點
當前提交
61da78fbbe
共有 1 個文件被更改,包括 15 次插入0 次删除
  1. 15 0
      README.md

+ 15 - 0
README.md

@@ -211,6 +211,21 @@ matplotlib-cpp.
 
 
 If you prefer to use CMake as build system, you will want to add something like this to your
 If you prefer to use CMake as build system, you will want to add something like this to your
 CMakeLists.txt:
 CMakeLists.txt:
+
+**Recommended way(since CMake 3.12):**
+
+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).
+
+NumPy is optional here, delete it from cmake script, if you don't need it.
+
+```cmake
+find_package(Python2 COMPONENTS Development NumPy)
+target_include_directories(myproject PRIVATE ${Python2_INCLUDE_DIRS} ${Python2_NumPy_INCLUDE_DIRS})
+target_link_libraries(myproject Python2::Python Python2::NumPy)
+```
+
+**Legacy way(unrecommended):**
+
 ```cmake
 ```cmake
 find_package(PythonLibs 2.7)
 find_package(PythonLibs 2.7)
 target_include_directories(myproject PRIVATE ${PYTHON_INCLUDE_DIRS})
 target_include_directories(myproject PRIVATE ${PYTHON_INCLUDE_DIRS})