-
Notifications
You must be signed in to change notification settings - Fork 26
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
Hard to deal with shared library #153
Comments
Thanks for the suggestions. None of our use cases ever use the shared library or install it, so it really hasn't gotten much attention. Would you propose disabling the ability to make both the static and shared libraries at the same time? If not how would you distinguish between them? |
@phlptp thank you for a quick reply,
In my experience there were no necessarity to create both static and shared libs at the same time. But I have seen such option few times even in quite big libraries (as I remember I think that BUT regarding how if I understand correct Also I expect that if a library provides all the three |
Add `units_export.h` to `install/insclude/units` dir #153
Hi,
I just started
units
library and I have found some problematic points when dealing with shared units library.I successively installed shared units library with (Windows 10, MSVC 2019 x64):
cd C:/units
mkdir d
cd d
cmake .. -DUNITS_BUILD_SHARED_LIBRARY=ON -DUNITS_BUILD_STATIC_LIBRARY=OFF -DUNITS_BUILD_WEB_SERVER=OFF -DUNITS_ENABLE_TESTS=OFF
cmake --build . --config Debug
cmake --install . --prefix ../install_d --config Debug
Then I create new cmake project
units_test
where I want to check units functionality. Here is the simpleCMakeLists.txt
of myunits_test
program:and I pass
-Dunits_DIR=/path/to/units/install_d/lib/cmake
argument when configuring myunits_test
project.First of all why you named differently
units-shared
target instead of simplyunits
? I have seen this once in another library and this confuses me because that makes me to hardcode my CMake script to allow linking to third party library if it is built in static or shared mode.Then in your examples you include headers as
#include <units/units.hpp>
but if I installedunits
then I can see the folder structure is:thus to include installed
units
I can only do#include <units.hpp>
. This adds difficulties when somebody wil use my library (that depends onunits
) and linkunits
viaadd_subdirectory(...)
. My#include <units.hpp>
will give error because the right way in this case would be#include <units/units.hpp>
Also when trying to link to installed shared library I get error that
units_decl.hpp
can't findunits/units_export.h
. So I have to manually create folderunits
insideinstall_d/include/
and copyunits_export.h
(I guess it is automatically generated by CMake) there.I propose:
units-shared
cmake target to standardunits
(do not make difference between shared/static/interface (header only) target`;install
we should install header files ininstall/include/units
folder;units_export.h
when doing installation.P.S. You made a great library and I can see that it will help me a lot! Thank you!
The text was updated successfully, but these errors were encountered: