简体   繁体   中英

FindPython vs find_package(Python ....)

In CMake 3.12 the FindPython module was introduced to help find the Python interpreter and other components.

However, I continue to see many examples using find_package(Python ...) .

Which should I use if I can guarantee I'm using CMake 3.12? What is the relationship between the two?

There is no difference. The find_package(Python ...) call looks for a module named FindPython.cmake first in CMAKE_MODULE_PATH , then in the standard CMake installation folder (where it will be found for sure).

Are you expecting to see include(FindPython) ? If so, that's bad practice. One should only load FindXYZ.cmake modules via find_package(XYZ) . This applies all the way back to CMake 2.x.

Which should I use if I can guarantee I'm using CMake 3.12?

You should use find_package(Python ...) , exactly as the documentation suggests. https://cmake.org/cmake/help/v3.12/module/FindPython.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM