Skip to content

Commit

Permalink
Find pybind11 in python/CMakeLists.txt
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters committed Nov 5, 2024
1 parent 4083472 commit b9f4d04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
16 changes: 4 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,11 @@ if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
find_package(Python3 COMPONENTS Interpreter)
else()
find_package(Python3 COMPONENTS Interpreter Development)
find_package(Python3
COMPONENTS Interpreter
OPTIONAL_COMPONENTS Development)
if (NOT Python3_Development_FOUND)
GZ_BUILD_WARNING("Python development libraries are missing: Python interfaces are disabled.")
else()
set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 CONFIG QUIET)

if (pybind11_FOUND)
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()
endif()
endif()

Expand Down Expand Up @@ -164,7 +156,7 @@ add_subdirectory(conf)
#============================================================================
# gz transport python bindings
#============================================================================
if (pybind11_FOUND AND NOT SKIP_PYBIND11)
if (Python3_Development_FOUND AND NOT SKIP_PYBIND11)
add_subdirectory(python)
endif()

Expand Down
15 changes: 13 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
cmake_minimum_required(VERSION 3.22.1)
set(GZ_TRANSPORT_VER 14)
project(gz-transport${GZ_TRANSPORT_VER}-python VERSION ${GZ_TRANSPORT_VER})
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 REQUIRED)
find_package(gz-transport${PROJECT_VERSION_MAJOR} REQUIRED)
set(PROJECT_LIBRARY_TARGET_NAME "gz-transport${PROJECT_VERSION_MAJOR}::gz-transport${PROJECT_VERSION_MAJOR}")
# require python dependencies to be found
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(CMAKE_REQUIRE_FIND_PACKAGE_pybind11 TRUE)
include(GNUInstallDirs)
include(CTest)
endif()

set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 CONFIG QUIET)

if (pybind11_FOUND)
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
else()
message(WARNING "pybind11 is missing: Python interfaces are disabled.")
return()
endif()

if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
if(NOT Python3_SITEARCH)
# Get install variable from Python3 module
Expand Down

0 comments on commit b9f4d04

Please sign in to comment.