@@ -78,9 +78,33 @@ if (BUILD_SDF)
7878 # available during build time
7979 set (GZ_TOOLS_VER 2)
8080
81+ #################################################
82+ # Find python
83+ if (SKIP_PYBIND11)
84+ message (STATUS "SKIP_PYBIND11 set - disabling python bindings" )
85+ find_package (Python3 REQUIRED COMPONENTS Interpreter)
86+ else ()
87+ find_package (Python3 REQUIRED
88+ COMPONENTS Interpreter
89+ OPTIONAL_COMPONENTS Development
90+ )
91+ if (NOT Python3_Development_FOUND)
92+ GZ_BUILD_WARNING("Python development libraries are missing: Python interfaces are disabled." )
93+ else ()
94+ set (PYBIND11_PYTHON_VERSION 3)
95+ find_package (pybind11 2.4 CONFIG QUIET )
96+
97+ if (pybind11_FOUND)
98+ message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION} ." )
99+ else ()
100+ GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled." )
101+ message (STATUS "Searching for pybind11 - not found." )
102+ endif ()
103+ endif ()
104+ endif ()
105+
81106 #################################################
82107 # Copied from catkin/cmake/empy.cmake
83- include (GzPython)
84108 function (find_python_module module)
85109 # cribbed from http://www.cmake.org/pipermail/cmake/2011-January/041666.html
86110 string (TOUPPER ${module} module_upper)
@@ -121,29 +145,6 @@ if (BUILD_SDF)
121145 gz_find_package(gz-utils2 REQUIRED COMPONENTS cli)
122146 set (GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR})
123147
124- ########################################
125- # Python interfaces
126- if (NOT PYTHON3_FOUND)
127- GZ_BUILD_ERROR("Python is missing - Needed to build/embed xml schemas" )
128- else ()
129- message (STATUS "Searching for Python - found version ${Python3_VERSION} ." )
130-
131- if (SKIP_PYBIND11)
132- message (STATUS "SKIP_PYBIND11 set - disabling python bindings" )
133- else ()
134- set (PYBIND11_PYTHON_VERSION 3)
135- find_package (pybind11 2.4 QUIET )
136-
137- if (${pybind11_FOUND} )
138- find_package (Python3 ${GZ_PYTHON_VERSION} REQUIRED COMPONENTS Development)
139- message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION} ." )
140- else ()
141- GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled." )
142- message (STATUS "Searching for pybind11 - not found." )
143- endif ()
144- endif ()
145- endif ()
146-
147148 gz_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS)
148149
149150 gz_create_packages()
0 commit comments