Skip to content

Commit

Permalink
Add option to disable building python bindings (#1637)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Aug 15, 2022
1 parent bfbe868 commit 9fc345c
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ endif()
include(test/find_dri.cmake)
FindDRI()

option(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION
"Install python modules in standard system paths in the system"
option(SKIP_PYBIND11
"Skip generating Python bindings via pybind11"
OFF)

option(USE_DIST_PACKAGES_FOR_PYTHON
include(CMakeDependentOption)
cmake_dependent_option(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION
"Install python modules in standard system paths in the system"
OFF "NOT SKIP_PYBIND11" OFF)

cmake_dependent_option(USE_DIST_PACKAGES_FOR_PYTHON
"Use dist-packages instead of site-package to install python modules"
OFF)
OFF "NOT SKIP_PYBIND11" OFF)

#============================================================================
# Search for project-specific dependencies
Expand Down Expand Up @@ -189,24 +194,27 @@ set(Protobuf_IMPORT_DIRS ${gz-msgs9_INCLUDE_DIRS})

#--------------------------------------
# Find python
include(GzPython)
find_package(PythonLibs QUIET)
if (NOT PYTHONLIBS_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 ${PYTHONLIBS_VERSION_STRING}.")

set(PYBIND11_PYTHON_VERSION 3)
find_package(Python3 QUIET COMPONENTS Interpreter Development)
find_package(pybind11 2.2 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()
find_package(PythonLibs QUIET)
if (NOT PYTHONLIBS_FOUND)
GZ_BUILD_WARNING("Python is missing: Python interfaces are disabled.")
message (STATUS "Searching for Python - not found.")
else()
message (STATUS "Searching for Python - found version ${PYTHONLIBS_VERSION_STRING}.")

set(PYBIND11_PYTHON_VERSION 3)
find_package(Python3 QUIET COMPONENTS Interpreter Development)
find_package(pybind11 2.2 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()
# Plugin install dirs
set(GZ_SIM_PLUGIN_INSTALL_DIR
Expand Down

0 comments on commit 9fc345c

Please sign in to comment.