Skip to content

Commit

Permalink
Find Python3 directly, not with GzPython
Browse files Browse the repository at this point in the history
This removes the use of gz-cmake's GzPython in favor
of a single call to find_package(Python3). This allows
setting Python3_EXECUTABLE to specify which python
version to use and is needed on macOS.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Jan 24, 2024
1 parent 764a04b commit 3b3a670
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ option(SKIP_PYBIND11

# Python interfaces vars
include(CMakeDependentOption)
include(GzPython)
cmake_dependent_option(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION
"Install python modules in standard system paths in the system"
OFF "NOT SKIP_PYBIND11" OFF)
Expand Down Expand Up @@ -135,25 +134,18 @@ gz_find_package(SQLite3

########################################
# Python interfaces
if (NOT PYTHON3_FOUND)
GZ_BUILD_WARNING("Python is missing: Python interfaces are disabled.")
message (STATUS "Searching for Python - not found.")
if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
else()
message (STATUS "Searching for Python - found version ${Python3_VERSION}.")
set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 QUIET)

if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
if (${pybind11_FOUND})
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
find_package(Python3 REQUIRED COMPONENTS Development Interpreter)
else()
set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 QUIET)

if (${pybind11_FOUND})
find_package(Python3 ${GZ_PYTHON_VERSION} REQUIRED COMPONENTS Development)
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
else()
GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled.")
message (STATUS "Searching for pybind11 - not found.")
endif()
GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled.")
message (STATUS "Searching for pybind11 - not found.")
endif()
endif()

Expand Down

0 comments on commit 3b3a670

Please sign in to comment.