CMakeLists Rhino Plugin C++


Why there is no example how C++ Rhino Plugin could be compiled using CMake?

The reason to ask, is that sharing your C++ plugin that links 3rd party libraries can be relatively difficult.

If there is one, it would good to have.

Hi @Petras1,

CMake doesn’t compile - it just creates make files. And since only Visual C++ is supported for C++ plug-ins, it doesn’t make a whole lot of sense to support it.

What library are you trying to use?

— Dale

Hi Dale,

What do you mean it does not compile? I am using it to compile executables, shared .dlls or static libs.

There are bunch of 3rd parties like Boost, Eigen, Open3D, PCL, CGAL, Cilantro, 3D viewers and others with their differences depending on a project. I know how to link them manually through Visual Studio IDE, but seems it is easier to pass onr CMakeLists.txt file rather than instructions for setting a project manually.

CMake is not a compiler. It uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform.

Most of the tools you mention are available on vcpkg, which should make using in plug-in projects fairly easy.

– Dale

Dear @Dale vcpkg package does not work on some of the previously mentioned libraries specially on Windows.

It would be really nice if some of you could invest time in providing an example on CMake.
It can be even without linking external libraries.

Maybe you just need this?

– Dale

Thanks for a reference but I am searching how to link libraries.

Can it be that McNeel does not provide this explanation partly because Rhino is commercial software? And majority of the libraries I used before are open-source. CMakeLists seems to be one of stadard distribution even together with vcpkg package manager. Maybe there could be something done with OpenNurbs.

Not at all. We just don’t get many requests for this.

– Dale

I’ve been slowly adding this to OpenNURBS. It just takes time and other projects always seem to get in the way.

1 Like

Fingers crossed we can see this development;)

I use these functions to link libraries on Windows with CMake for Rhino:



Thats super good.

Would you mind sharing the full example folder?

a) CMakeLists.txt
b) main.cpp file

Hi Steve, some time ago I created a basic CMakeLists.txt for OpenNURBS in my GitHub branch:

Feel free to use any parts of it that are useful. Or if you published your work as a GitHub PR I would be happy to contribute to it.

There was also this PR created awhile ago, though it may have included too many other changes:

1 Like

Thanks, but unfortunately it is a bit more complicated. We have a number of closed source files that we need to account for in our internal build and we need to get this set up for all supported operating systems.

Sorry from bringing back this thread but I was wondering if, in the meanwhile, someone came up with a CMake template to compile a C++ Rhino plug-in at least on Windows 11x? The only trace of a similar topic can be found in an another thread here. Many thanks in advance for any hints!:pray:

Yes, we actually do build a rather complex C++ Rhino plugin with CMake.
Reasons are pretty much the same as in the original question: it is easier to integrate 3rd party libraries e.g. boost, catch etc. Plus for us it is much easier to maintain a CMake script with a team of developers than having to work with .sln and .vcxproj files.

However, it took me several days and a lot of headache to sort out all dependencies and flags required to build the plugin against Rhino and the resulting CMake scripts have ~300 lines.
Things I did particularly fight with:

  • Precompiled headers and how to reuse them for multiple OBJECT libraries and unit tests
  • Unit tests in general (but that is more related to the way a plugin is built as a .dll)
  • Using debug mode while linking to a release build of Rhino
  • Importing Rhino SDK property sheets (from C:\Program Files\Rhino 7 SDK\PropertySheets)

I am not allowed to share the CMakeLists as is, would have to strip out all confidential internals first.
I would also love to have a boilerplate CMake setup from the Rhino team!

1 Like