Hi all,
new user here, my name is Jörg, but I usually go as “dunc” online… this is my first post here, and it’s really more of a very generic/basic cmake tutorial question, so you gents might consider it “too basic”. That’s all fine, but I’m struggling to find a good example, so I thought I ask as close to the source as possible.
Upfront: I am absolutely fine with answers like “RTFM!” or “plenty of examples available, just check them out”… however, I am unable to find the correct stuff online, so in case your answers sway that way, I would appreciate at least some pointers, if possible.
Here’s what I’d like to achieve with cmake (using C/C++):
a) have a very basic common INTERFACE header file, defining API functionality to be exported by a shared library
b) have a very basic SHARED library implementation which implements above API (this shared lib might be replaced later on by a similar shared lib that implements tha same API)
c) have a consumer APPLICATION that uses the shared library (and in case s/o replaces shared lib implementation 1 with implementation 2 later on, it is transparent to the consumer app)
So, as you can tell, extremely basic stuff. And yes, I know how to code and implement the C/C++ side of things.
My questions are obviously regarding “how to properly create a cmake config for this, which takes care of all the import export handling, as well as is universal enough to work for both DLLs on Windows and so on Linux”?
I know about Wiki examples like BuildWindowsDLL, which is targeted at cmake 2.8.something. But even here, there never is a complete example roundtrip availabe which combines everything, instead the reader is forced (well, at least I am) to be able to work with snippets and deduce the actual correct combination of cmake options. Given the fact that cmake offers SO MUCH options for special cases, I fail to specifiy what the minimum working base config for such a task would be.
Like “the interface library should be configured like this, we will use a minimal interface with only one exposed method as an example” … “the shared lib should be configured like this, we implement only the single exposed method from the interface” … “this is what you need to add as macros to the code, this is what cmake handles for you” … “this is where you need to handle Windows DLL and Unix SO seperately, this is where cmake handles it for you in a unified way” … “this is how to configre the app via cmake to consume the shared library, and this is the corresponding app code that YOU need to take care of, while THESE parts will be handled by cmake”.
I hope you understand what I’m asking for, and I also hope this is not considered too trivial or too basic for this forum. If it is, no hard feelings, I will try to look around elsewhere.
Thanks upfront and kind regards,
dunc