Building and integrating your module
Writing a module’s code says nothing about how it’s built — and two approaches, very different from each other, are equally legitimate depending on what you plan to do with it.
Working on your own
Nothing requires going through the ost/ostmodules repository: a module can live in its own repository, with its own CMakeLists.txt, drawing inspiration from ost/ostmodules’s rather than slavishly copying it. Two pieces of information are enough to locate a real OST installation:
find_path(OST_INCLUDE_DIR ost/indimodule.h)
find_library(OST_LIBRARY_BASE NAMES libostbasemodule.so PATHS /usr/lib /usr/lib/x86_64-linux-gnu)
find_library(OST_LIBRARY_INDI NAMES libostindimodule.so PATHS /usr/lib /usr/lib/x86_64-linux-gnu)ost/ostmodules does exactly that in cmake_modules/FindOSTSERVER.cmake — the simplest approach is still to read that file directly rather than guess it.
For a purely Basemodule module, only OST_LIBRARY_BASE is needed; OST_LIBRARY_INDI is only required for an IndiModule.
Contributing to the shared repository
For the module to be visible and maintained alongside the others, it joins ost/ostmodules:
- Clone the repository, create a branch.
- Add your own block in
CMakeLists.txt, modeled on a simple existing module (osthello, for instance):
add_library(ostmonmodule SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/modules/monmodule/monmodule.h
${CMAKE_CURRENT_SOURCE_DIR}/src/modules/monmodule/monmodule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/modules/monmodule/monmodule.qrc
)
target_link_libraries(ostmonmodule PRIVATE
${OST_LIBRARY_BASE} # ou ${OST_LIBRARIES} (base + indi) pour un IndiModule
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Widgets
Threads::Threads
z
)
target_compile_definitions(ostmonmodule PRIVATE MONMODULE_MODULE)- Add
ostmonmoduleto theinstall(TARGETS ...)list, a little further down in the same file. - Open a merge request.
Every module repeats this block by hand — there is currently no CMake function that factors it out. Copying the block from a module that’s already close (an IndiModule for an IndiModule, for example osthelloindi) avoids omissions more reliably than rewriting it from scratch.