Closed sizeak closed 1 year ago
Hello @simoncent, sorry for the late reply. I'm in the process of modernizing the CMake build myself and I'm interested in using some of this. There's only one thing, you mentioned that it allows building a shared library in addition to a static library, but I'm having a look at the code and it only toggles between generating one and the other, unless I'm missing something?
No, you're not missing anything, you're absolutely correct. The change I made simply allows you to toggle between building a shared or static library, exactly as you described.
What I meant by "in addition to a static library", is that previously there wasn't a way to easily toggle the build to create a shared library, it was a static build only; additionally, exposing the CMake BUILD_SHARED_LIBS
flag as an option
is quite common and makes it easier to compose the project with other CMake based projects, i.e. I can set the flag on my top level CMake project of which I pull this library in as a dependency, and pass my CMake environment down and this will then automatically build a shared / static library to match the parent project.
@simoncent thanks a lot for your reply. I'd make sure to add that option to the final CMake config.
This PR adds support for building a shared library with CMake, in addition to a static library. The output library type can be toggled with
-DBUILD_SHARED_LIBS=ON
or-DBUILD_SHARED_LIBS=OFF
.I've also updated it to rely more on the built in CMake installation behaviour and to use target specific configurations over globals.
CMake now recommended to use lower case for commands etc. so I have updated where needed.
Also closes #40
Happy to discuss any changes needed to get this merged, thanks!