CMake | find_package(Python3) documentation confusion

I’ve tried the following with cmake 3.28 (ubuntu 24.04) and 4.04 (mac arm).

I had expected to find libraries and include directories.

Could someone please explain why Python3_Development.SABIModule_FOUND is TRUE, but the associated variables are empty? There is probably a good reason for this, but the documentation is not clear about the behavior.

======

cmake_minimum_required(VERSION 3.26)

project(python_tester)

find_package(Python3 REQUIRED COMPONENTS Interpreter Development.SABIModule)
message(STATUS "Python3_Development.SABIModule_FOUND -> ${Python3_Development.SABIModule_FOUND}")
get_target_property(_sabi_path Python3::SABIModule LOCATION)
message(STATUS "Python3::SABIModule -> ${_sabi_path}")
message(STATUS "SABI libs: ${Python3_SABI_LIBRARIES}")
message(STATUS "SABI include dirs: ${Python3_SABI_INCLUDE_DIRS}")

=======

cmake .
-- Python3_Development.SABIModule_FOUND -> TRUE
-- Python3::SABIModule -> _sabi_path-NOTFOUND
-- SABI libs: 
-- SABI include dirs: 
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/johnsonhj/TESTER

Marc Chevrier commented:

The real artifacts defined by a component depends on the platform.
If you are on Linux or macOS, the libraries are not required for the development using the Python Stable ABI. This explains why the Python3_SABI_LIBRARIES variable is empty, as well as the LOCATIONtarget property. Only the include directories are defined by the variable Python3_INCLUDE_DIRS and the INTERFACE_INCLUDE_DIRECTORIEStarget property.
By the way, the variable Python3_SABI_INCLUDE_DIRS is never defined by the Python3 module.

In practice, if you are relying on the targets defined by the Python3 module as well as the python3_add_library() command, you don’t have to worry about the variables…

And to finish, it is assumed that the developers using this module are a minimum aware of what are the constraints and usages regarding python developments. This is not the role of the documentation of the Python3module to provide such development details.

I was aware that the Python3_SABI_LIBRARIES are not needed on Linux and macOS. I had expected them to be the same as Python3_LIBRARIES. The most confusing part was that

Python3_Development.SABIModule_FOUND → TRUE

but all the other *SABI* variables were empty.