From 87c80e7c9b4c928586b7094149025358fc7d661d Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sun, 29 Sep 2024 01:15:35 +0200 Subject: [PATCH] Support compilation of bindings as standalone project Signed-off-by: Silvio Traversaro --- python/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e0e935fc..eb1a4ba5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,3 +1,18 @@ +# Detect if we are doing a standalone build of the bindings, using an external gz-transport +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + cmake_minimum_required(VERSION 3.16) + 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}") + include(CTest) + if(BUILD_TESTING) + enable_testing() + endif() +endif() + if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION) if(NOT Python3_SITEARCH) # Get install variable from Python3 module