You can use the built code from the slicer source to build new libraries and even full executables and applications. This is essentially what the Extension build system does so just using CMake you should be able to add anything you need.
Another option could be to create a custom application as discussed here.