Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow static and shared builds #78

Open
brechtsanders opened this issue Sep 30, 2020 · 3 comments
Open

Allow static and shared builds #78

brechtsanders opened this issue Sep 30, 2020 · 3 comments

Comments

@brechtsanders
Copy link

Will a shared library also be supported?

If you remove the STATIC argument from add_library() in CMakeLists.txt then the user can decide to build either a static or shared library bu supplying cmake parameter -DBUILD_SHARED_LIBS:BOOL=OFF or -DBUILD_SHARED_LIBS:BOOL=ON respectively.

Note that to support building a shared library (DLL) on Windows you will need to add the necessary __declspec(dllexport) and __declspec(dllimport) stuff for exported classes.

@dhorlick
Copy link

If we're not going to do this, then I recommend we either add set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS_INIT} -fPIC") or set target property POSITION_INDEPENDENT_CODE to True, to make it possible to link against midifile.a

@craigsapp
Copy link
Owner

Allowing an easy way to compile dynamic or static library versions is a good idea. I don't program on Windows (and only occasionally work with cmake), so if you can provide a pull request (best) or demo code here, that functionality should be added. The library is so small I have not bothered using it as a dynamic library so for.

@dhorlick
Copy link

if you can provide a pull request (best) or demo code here, that functionality should be added

Done!

The library is so small I have not bothered using it as a dynamic library so for.

Indeed… since commenting, I decided it would be better not to dynamically link it into my own project, after all. 😄

Thanks for this library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants