Skip to content

Commit a48b893

Browse files
committed
Adapt package finding logic
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
1 parent 97ad436 commit a48b893

2 files changed

Lines changed: 11 additions & 33 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ endif()
9999
if (SKIP_PYBIND11)
100100
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
101101
else()
102-
<<<<<<< HEAD
103102
#include(GzPython) TODO: allow to specify for what it should search and then
104103
# the code below can be removed; e.g. pybind needs Interpreter and Development components
105104
# see https://pybind11.readthedocs.io/en/stable/cmake/index.html#new-findpython-mode
@@ -112,36 +111,18 @@ else()
112111
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
113112
find_package(PythonLibs QUIET)
114113
# we found the interpreter but did we also find the libs? both are required
115-
set(Python3_FOUND ${PYTHONLIBS_FOUND})
114+
set(Python3_Development_FOUND ${PYTHONLIBS_FOUND})
116115
set(Python3_VERSION ${PYTHONLIBS_VERSION_STRING})
117116
endif()
118117
else()
119118
find_package(Python3 QUIET COMPONENTS Interpreter Development)
120119
endif()
121120

122-
if (NOT Python3_FOUND)
121+
if (NOT Python3_Development_FOUND)
123122
GZ_BUILD_WARNING("Python3 is missing: Python interfaces are disabled.")
124123
message (STATUS "Searching for Python3 - not found.")
125124
else()
126125
message (STATUS "Searching for Python3 - found version ${Python3_VERSION}.")
127-
128-
set(PYBIND11_PYTHON_VERSION 3)
129-
find_package(pybind11 2.2 QUIET)
130-
131-
if (${pybind11_FOUND})
132-
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
133-
else()
134-
GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled.")
135-
message (STATUS "Searching for pybind11 - not found.")
136-
endif()
137-
=======
138-
find_package(Python3 REQUIRED
139-
COMPONENTS Interpreter
140-
OPTIONAL_COMPONENTS Development
141-
)
142-
if (NOT Python3_Development_FOUND)
143-
GZ_BUILD_WARNING("Python development libraries are missing: Python interfaces are disabled.")
144-
>>>>>>> 17deea2b (Permit building python bindings separately from gz-math library (#636))
145126
endif()
146127
endif()
147128

src/python_pybind11/CMakeLists.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
<<<<<<< HEAD
2-
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
3-
# TODO: remove once the minimum CMake version is increased
4-
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
5-
# pybind11 logic for setting up a debug build when both a debug and release
6-
# python interpreter are present in the system seems to be pretty much broken.
7-
# This works around the issue.
8-
set(PYTHON_LIBRARIES "${PYTHON_DEBUG_LIBRARIES}")
9-
endif()
10-
=======
111
# Detect if we are doing a standalone build of the bindings, using an external gz-math
122
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
133
cmake_minimum_required(VERSION 3.22.1)
14-
set(GZ_MATH_VER 8)
4+
set(GZ_MATH_VER 7)
155
project(gz-math${GZ_MATH_VER}-python VERSION ${GZ_MATH_VER})
166
find_package(gz-math${PROJECT_VERSION_MAJOR} REQUIRED)
177
set(PROJECT_LIBRARY_TARGET_NAME "gz-math${PROJECT_VERSION_MAJOR}::gz-math${PROJECT_VERSION_MAJOR}")
@@ -20,6 +10,14 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2010
set(CMAKE_REQUIRE_FIND_PACKAGE_pybind11 TRUE)
2111
include(GNUInstallDirs)
2212
include(CTest)
13+
elseif(${CMAKE_VERSION} VERSION_LESS "3.12.0")
14+
# TODO: remove once the minimum CMake version is increased
15+
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
16+
# pybind11 logic for setting up a debug build when both a debug and release
17+
# python interpreter are present in the system seems to be pretty much broken.
18+
# This works around the issue.
19+
set(PYTHON_LIBRARIES "${PYTHON_DEBUG_LIBRARIES}")
20+
endif()
2321
endif()
2422

2523
set(PYBIND11_PYTHON_VERSION 3)
@@ -30,7 +28,6 @@ if (${pybind11_FOUND})
3028
else()
3129
message(WARNING "pybind11 is missing: Python interfaces are disabled.")
3230
return()
33-
>>>>>>> 17deea2b (Permit building python bindings separately from gz-math library (#636))
3431
endif()
3532

3633
message(STATUS "Building pybind11 interfaces")

0 commit comments

Comments
 (0)