Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add imgui as a py3 loadable module
Browse files Browse the repository at this point in the history
fredroy committed Nov 16, 2023
1 parent 5c1ef79 commit 63d4a01
Showing 3 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SofaImGui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
20 changes: 20 additions & 0 deletions SofaImGui/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.")
36 changes: 36 additions & 0 deletions SofaImGui/bindings/Module_SofaImGui.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Contact information: contact@sofa-framework.org *
******************************************************************************/

#include <pybind11/pybind11.h>

#include <SofaImgui/init.h>


namespace py { using namespace pybind11; }

namespace sofaimgui::python3
{

PYBIND11_MODULE(SofaImGui, m)
{
sofaimgui::init();
}

} // namespace sofaimgui::python3

0 comments on commit 63d4a01

Please sign in to comment.