Closed gmbeard closed 5 years ago
@gmbeard I never even considered this, but it's a valid point. Thank you for bringing it to my attention.
I think your proposed solution is fine, so I'd gladly accept a PR! If you decide to do this, could you please include relevant documentation in the README?
@mandreyel Sure, I will update the docs. No problem. I'm pretty close to sending a PR but I only have access to Windows and a FreeBSD host for compiling. Are you able to test compilation on any other OSes?
@gmbeard Awesome! I only have access to Linux, but we could create an issue asking for help in testing on other platforms, although I think coverage is pretty high already.
Because the Windows version of mio uses the WinAPI, it would be useful to allow consumers to control how much of the WinAPI is pulled into their own applications. Being header only,
#define
s such asWIN32_LEAN_AND_MEAN
will leak intoupstreamdownstream code. This may cause an inconvenience if anyupstreamdownstream code needs to use APIs such as Windows Cryptography, GDI, etc. This SO answer provides a nice list of whatWIN32_LEAN_AND_MEAN
disables.Of course, consumers can still include the individual WIndows headers they need explicitly, and this could well be a suitable solution, instead of addressing this in mio.
My initial suggestion (on Reddit) was to expose a CMake option (such as
MIO_MINIMAL_WIN_API
) to allow consumers to control this. On reflection, this maybe not ideal; As I understand, this option would only be controllable at the point mio is configured, not once it's installed. A better solution would be to expose multiple CMake targets, instead. For example,mio::mio
would default to a fully stripped down WinAPI, whilemio::mio_full_winapi
wouldn't set any WinAPI definitions. This way, the consumer can choose whichever suits their project.All existing
#define
s forWIN32_LEAN_AND_MEAN
, etc. would need to be removed from the header files for this to work.This could be implemented with somthing similar to...
It could probably be structured better (with
include()
s, etc) but you get the idea. I'm happy to attempt a PR for this, if needed.