diff --git a/SofaImGui/CMakeLists.txt b/SofaImGui/CMakeLists.txt index 578b2e3340..05dd7c9202 100644 --- a/SofaImGui/CMakeLists.txt +++ b/SofaImGui/CMakeLists.txt @@ -103,6 +103,11 @@ target_link_libraries(${PROJECT_NAME} PUBLIC SofaGLFW Sofa.GL.Component.Renderin set_target_properties(nfd PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(${PROJECT_NAME} PRIVATE nfd glfw) +find_package(SofaPython3 QUIET) +if(SofaPython3_FOUND) + add_subdirectory(bindings) +endif() + sofa_create_package_with_targets( PACKAGE_NAME ${PROJECT_NAME} PACKAGE_VERSION ${Sofa_VERSION} diff --git a/SofaImGui/bindings/CMakeLists.txt b/SofaImGui/bindings/CMakeLists.txt new file mode 100644 index 0000000000..71bddf0cff --- /dev/null +++ b/SofaImGui/bindings/CMakeLists.txt @@ -0,0 +1,20 @@ +project(Bindings_SofaImGui) + +set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/Module_SofaImGui.cpp +) + +if (NOT TARGET SofaPython3::Plugin) + find_package(SofaPython3 REQUIRED COMPONENTS SofaImGui Bindings.Sofa) +endif() + +SP3_add_python_module( + TARGET ${PROJECT_NAME} + PACKAGE SofaImGui + MODULE SofaImGui + DESTINATION / + SOURCES ${SOURCE_FILES} + DEPENDS SofaPython3::Plugin SofaPython3::Bindings.Sofa SofaImGui + +) +message("-- SofaPython3 bindings for SofaImGui will be created.") diff --git a/SofaImGui/bindings/Module_SofaImGui.cpp b/SofaImGui/bindings/Module_SofaImGui.cpp new file mode 100644 index 0000000000..c79df42073 --- /dev/null +++ b/SofaImGui/bindings/Module_SofaImGui.cpp @@ -0,0 +1,36 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2021 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by * +* the Free Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Contact information: contact@sofa-framework.org * +******************************************************************************/ + +#include + +#include + + +namespace py { using namespace pybind11; } + +namespace sofaimgui::python3 +{ + +PYBIND11_MODULE(SofaImGui, m) +{ + sofaimgui::init(); +} + +} // namespace sofaimgui::python3