-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix header installation path #33
Conversation
Do not install the headers in /usr/include/dragonbox-1.1.3/dragonbox but install them in /usr/include/dragonbox.
Thanks for the PR and sorry for the delay. I am currently not sure what is the common best practice, to include the version, or to not include the version. Do you have some other reference projects that I can look at? |
Sorry @danyspin97, I concluded that having an extra directory is a good thing, because it prevents people from accidently including the library without being explicit about using it. Adding the right include directory should not be a big issue for any build system you use I guess. So I close this PR. |
The problem is not the depth of the directory structure, but that the install location changes depending on the version used. Having different directories for different major versions (e.g. version 1, version 2) is common practice, but not for minor versions when one uses semantic versioning. |
@ecorm Thanks for the input. Do you know of some references that I can have a look at? |
@jk-jeon I don't have a reference off the top of my head to give you. Certainly not Ryu, as they messed things up like having really short function names in the global namespace, and also perhaps macros without a prefix to help avoiding clashes with other library/application macros. I'll see if I can find a reference/example and will get back to you. |
I don't agree with their approach, and it goes against the convention in Linux. Let's say I have an open-source library that depends on dragonbox. I don't want to impose which version of the dragonbox my users must have on their system, except for the major version (that is 1.x.x or 2.x.x). Let's say in my hypothetical library, I only impose major version 1 of dragonbox. If you follow the semantic versioning principle, then my users can supply any version 1.x.x of dragonbox, and my library should be able to compile with it, assuming it only uses features from the 1.0.0 release. For example: #ifndef MYLIBRARY_HPP
#define MYLIBRARY_HPP
#include <string>
#include <dragonbox/dragonbox.h>
// The following would be annoying to users who don't have the exact same version of dragonbox
// on their system. They would need to patch this source file!
// #include <dragonbox-1.1.3/dragonbox/dragonbox.h>
namespace mylib
{
inline std::string doubleToString(double x)
{
constexpr int buffer_length = 1 + // for '\0'
jkj::dragonbox::max_output_string_length<jkj::dragonbox::ieee754_binary64>;
char buffer[buffer_length];
return std::string(jkj::dragonbox::to_chars(x, buffer));
}
} // namespace mylib
#endif // MYLIBRARY_HPP If my library depends on dragonbox 1.1 or later because of new features or bugfixes, that could be checked with version macros: #ifndef MYLIBRARY_HPP
#define MYLIBRARY_HPP
#include <string>
#include <dragonbox/dragonbox.h>
#if JKJ_DRAGONBOX_VERSION_MAJOR != 1 || JKJ_DRAGONBOX_VERSION_MINOR < 1
#error MyLibrary requires dragonbox 1.1 or later
#endif
Having dragonbox 1.1 or later installed could also be checked with my library's CMake script if dragonbox exports things correctly in its CMake scripts. If you follow semantic versioning, and you release a version 2 of dragonbox where you allow yourself to break its API, then you should install it under a #ifndef MYLIBRARY_HPP
#define MYLIBRARY_HPP
#include <string>
#ifdef MYLIBRARY_USE_LEGACY_DRAGONBOX
#include <dragonbox/dragonbox.h>
#else
#include <dragonbox-2/dragonbox.h>
#endif
If a developer needs to maintain multiple versions of dragonbox for different projects, they can use cmake --install . --prefix /home/me/code/dragonbox-1.1.3 In the developer's CMakeLists.txt for their app, they can add #include <dragonbox/dragonbox.h> |
Whenever you see
It's because the library didn't strictly follow the semantic versioning convention. Some apps/libraries in the system depend on the behavior of somelib v1.1 whereas others depend on the behavior of v1.2. If one is careful not to alter behavior within a major version, then any app should be able to use the latest version of If the behavior of dragonbox can alter between minor versions (say, the decimal string output like removing trailing zeroes), and there's a chance that apps depend on the old behavior, then there may be an argument for installing under Whenever you see
It means the library properly followed the semantic versioning convention where they only broke the API in major versions. Some system apps are relying on the old |
@ecorm I see what you mean. For the first point about the Linux convention, I don't have much to say. There was a related comment on that in the issue thread I mentioned. At this point I'm not conclusive on this matter. I need to have some more research on this topic. For the second point about the include directory, I think I'm not agreeing with you on it. I think deciding which version of library to include is basically the job of build system, not of source code. If the user correctly set up the include directory (which I believe should be automatic if the CMake script of this repo is written correctly), then the source code just need to have Your suggestion about the possibility of coexistence of two different versions behind a macro switch seems tempting, but my gut feeling is that it is a brittle hack basically. Because, (1) we anyway need to have a single version of To be fair, we could also have an inline namespace to prevent the ODR issue, but anyway I feel uneasy about having multiple versions of the same library in a single project. Thanks a lot for all the input anyway. I have to think about this more. |
A note before continuing the discussion: dragonbox is now shipped in Linux distributions as it is a Libreoffice dependency.
I think a quick inspection of Having a major version like |
@danyspin97 Thanks for the reply. Would you mind opening an issue about this matter? I think it would be better to discuss further in an issue thread instead of a PR. Anyway, here is what I think right now:
|
Do not install the headers in /usr/include/dragonbox-1.1.3/dragonbox but install them in /usr/include/dragonbox.