0

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?

BeeOnRope
  • 60,350
  • 16
  • 207
  • 386

1 Answers1

1

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

Alex Reinking
  • 16,724
  • 5
  • 52
  • 86
  • Thanks Alex, this resolved my confusion. – BeeOnRope Jun 21 '22 at 23:47
  • @BeeOnRope To make sure your project gonna be built w/ the required CMake you can^W have to use `cmake_minimum_required(VERSION 3.12)` as the very first statement of your `CMakeLists.txt`. – zaufi Jun 22 '22 at 21:53