Building CustomOperator with CMake

Hello everybody!

I wanted to write a couple of custom CHOPs and I found a lot of useful online material that helped me understand the API, and I think that the CustomOperator repo is a great resource.
The only thing was that I couldn’t build the examples because I am working on a Mac and the repository only contains Visual Studio solutions. Moreover I wanted to use an external library in one of my custom CHOPs, and I could really easily integrate my library using CMake.

Suddenly I found this repo which uses CMake as a build system and I managed to compile my projects on my machine!

I just wanted to share with you my a fork of the CustomOperator repository into which I added the possibility to use CMake to build the examples provided by Derivative:
https://github.com/ddgg-el/CustomOperatorSamples
This fork is just a proof of concept and I am sure that it can be optimized or even simplified. So far I just worked on the CHOPs and on those TOPs which are not Cuda dependent (since they are the only ones that I could test), but I am planning to commit the DAT and the SOP folder soon.

To compile an Operator, let’s say the BasicFilterCHOP you can just:

% cd BasiFilterCHOP
% mkdir build && cd build

choose the Generator of your choice (Unix Makefiles, Xcode etc…) and build the project:

% cmake -G"Unix Makefiles" ..
% cmake --build .

this commands will produce a plugin folder inside the BasicFilterCHOP whre you can find your custom plugin.

I don’t know if this was already possible. I hope that it can be useful for someone

1 Like

Hey, can you generate a pull request on github? We’d be happy to look into merging this if you are interested.

Yes! Sure! Do you want me to finish the other OP families first?

Totally up to you, although it seems like you’ve deleted a lot of files in your current branch so you’d need to refork from a commit before those deletes to keep the commit history clean. It’s ok if some of the examples have CMake and others don’t

Done! I hope it will work. Let me know!
Today I’ll check if this building solution works on Windows as well