Embedding Panda into my repository

I really dislike the idea of having to install an SDK or a library to start working on my projects. That’s why i usually add libraries as submodules on my git projects and use CMake to statically link them to my application. Here’s a similar workflow:

github.com/Polytonic/Glitter

Bullet, Assimp, GLFW and others are added as submodules and, when i CMake my project, they get built and linked together. Much easier for everyone involved, self-contained and modular.

Anyway, i’ve been looking for a way to do this with Panda without any luck. The whole building process seems very complex. Is there any way to achieve a similar workflow with this engine?

Currently, it is only supported to build Panda with makepanda. It is a straightforward process that is explained in the README.md file. What will help is the fact that you can run Panda3D straight from the “built” directory that makepanda generates, without having to install Panda3D system-wide, so you can keep the build localised to your project directory.

CMake support is in the works, and you can test it out by checking out the “cmake” branch in GitHub.

Your feedback on how we can improve this workflow is always welcome.

Having to compile Panda separately from my project, with my own compilation flags, is a nightmare for anyone working in a team and with a CI/CD workflow. Not only everyone in the team would have to keep track of how to compile Panda, and with which options, but the build server as well. In our old project, we’ve used OGRE and Bullet, and we built it like i mentioned earlier: added as a submodule, configured our Cmake project to add it as a library and linked statically. Everything was contained in our project, everything we needed to was to clone, update the submodules, and run Cmake.

I’ve checked the CMake branch, but it couldn’t understand how it worked. It seems to be building the library for dynamic linking, everytime, assuming people have to install panda on their system first, before compiling our project. This really sucks. Panda should not act like a framework or a tool, but like a library that can be easily included. Just like Bullet does.

I’m not sure I understand the issue entirely. Surely you can configure CMake to run makepanda to build Panda inside a subdirectory of your project? Again, there’s absolutely no requirement for you to install Panda into your system for you to use it. It is fully self-contained and can be run directly from the build directory.

Is there maybe something you could share about the way you set up your previous project to build OGRE and Bullet, so that I could get a better understanding of how this works? If this is something that can be improved in the way Panda is built, I’d love to look into this.

github.com/urho3d/Urho3D/issues/1167

Panda becomes a simple module, that i can include at will from my own CMake project.

Any updates on this? Is this something that could be added to Panda?

An example from SDL:

set(SDL_STATIC ON)
add_subdirectory(SDL2) # sub-directory added as a git submodule to our project

add_executable(my_executable main.cpp)
target_link_libraries(my_executable SDL2-static)

Discussion from the Urho guys and included example solution:

urho3d.prophpbb.com/topic1701.html

    ExternalProject_Add(Urho3D
        SOURCE_DIR ${CMAKE_SOURCE_DIR}/dep/Urho3D
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DURHO3D_C++11=1 -DURHO3D_SAMPLES=0 -DURHO3D_LIB_TYPE=SHARED
                   -DURHO3D_USE_LIB_DEB=1 -DURHO3D_PCH=0 -DCMAKE_BUILD_TYPE=${CAKE_BUILD_TYPE}
                   ${URHO3D_EXTRA_PARAMS}
        BUILD_COMMAND make -j8
        BINARY_DIR ${CMAKE_BINARY_DIR}/Urho3D-build
        INSTALL_DIR ${CMAKE_BINARY_DIR}
    )

    add_custom_command(TARGET Urho3D POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/dep/Urho3D/bin/CoreData ${CMAKE_BINARY_DIR}/bin/CoreData
        COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/dep/Urho3D/bin/Data ${CMAKE_BINARY_DIR}/bin/Data
    )

    add_definitions (-DURHO3D_CXX11=1)
    include_directories (
        ${CMAKE_BINARY_DIR}/include
        ${CMAKE_BINARY_DIR}/include/Urho3D
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty/Bullet
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty/kNet
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty/Lua
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty/SDL
        ${CMAKE_BINARY_DIR}/include/Urho3D/ThirdParty/SRB
    )
    link_directories (
        ${CMAKE_BINARY_DIR}/lib
        ${CMAKE_BINARY_DIR}/lib/Urho3D
    )

Sure, that could be done with makepanda as well, by putting the appropriate makepanda commands in the ExternalProject_Add call. (In the future it will be made even slightly easier when we merge the cmake branch into master.)

The build makepanda produces is portable and does not need to be installed in order to be used, but can be used straight out of the build directory.

Thanks for the info. I guess i’ll wait for the next version.

This is now possible with the current master

FetchContent_Declare(panda GIT_REPOSITORY https://github.com/panda3d/panda3d.git GIT_TAG master)
FetchContent_GetProperties(panda)
if (NOT panda_POPULATED)
    FetchContent_Populate(panda)
    list(APPEND CMAKE_MODULE_PATH ${panda_SOURCE_DIR}/cmake/macros)
    list(APPEND CMAKE_MODULE_PATH ${panda_SOURCE_DIR}/cmake/modules)
    
        # set some options
    set(HAVE_PYTHON OFF)
    set(WANT_INTERROGATE OFF)
    set(BUILD_SHARED_LIBS OFF)
    #    set(USE_DELETED_CHAIN OFF) # probably reenable it later
    set(SUPPORT_IMMEDIATE_MODE ON)

    add_subdirectory(${panda_SOURCE_DIR} ${panda_BINARY_DIR})
endif ()


add_executable(pandagarten main.cpp)

target_link_libraries(pandagarten panda p3framework)