-
Notifications
You must be signed in to change notification settings - Fork 52
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
Refactoring CMakeLists #22
base: master
Are you sure you want to change the base?
Conversation
The situation with CMakeLists in this repo is pretty ambiguous, to put it mildly. This is not recommended way to use the library. It's not supported in any way, i.e. we don't test it, it's not documented, we can't be sure that it works as intended / at all / etc. @blacktea, you propose here a relatively large change that I can't even test manually, and, to be frank, many modifications here warrant a thoughtful explanation. I see at least a few minor syntactic problems (EOF newlines, broken indents, Given that nobody of the people who worked on these CMakeLists before reviewed it so far, @blacktea, could you explain in more detail, what is your idea behind using CMakeLists, i.e.:
|
I'd start with an explanation of my using the project. Firstly, I had to build The my proposal intend to simplify that. I have the following project struct: Demo/GeneratedCppFromKsy/CMakeLists.txt looks like:
Demo/CMakeLists.txt contains:
I suppose it's easy and natural way to use the project. If it's supposed to include kaitaistruct.* kaitaistream.* and generated files to a target project. I think it's not convinient and nobody to do that. Moreover, I think the project compiler would be able to create CMakeLists for generated files(similar with Demo/GeneratedCppFromKsy/CMakeLists.txt). Because, it seems as a pattern. I attached demo project to check it out (kaitai_tiny_example.zip). However, before it's needed to build
Please, tell me more details I'm ready to fix it and ready to support it. |
Actually, this is my first big question, what is your rationale to not just include The main problem with any dynamically linked library is that it impedes inlining of the simple methods like Performance aside, I'm also pretty surprised about "covenience". C++, unfortunately, never got any good single package management system like most modern languages have, so, introduction of any extra libraries is always a big mess. Even if you can solve the problem for, say, Linux (by packaging binary shared library for major distributions), it would be still a problem for OS X (yet another homebrew package?.. unlikely a popular solution), and for Windows (vcpkg and/or nugets? both have its own cons). Even if we'll package the runtime at some point as a shared library, I don't think that CMake compatibility layer would be the answer for everyone (or, even for everyone on *nix-like systems). People still use other build systems (QMake, scons, bazel, Gradle, Ninja, etc), people would want us to support some standards like
Ok, why can't we just use CMakeLists in your project to run kaitai-struct-compiler on .ksy files, i.e. using the very same principle as with C compiler that compiles .cpp → .cpp.o (and these never appear in source dir, only in build dir)? As far as I understand your current approach, you're not only building them manually, but you also compile them using |
So, you don't add source code of ZLIB library instead you find the already built library.
Some links related to your concerns (In short dynamic library does not have any impact on run-time performance):
There is an example: everybody uses OpenCV that does a lot of reading and calculating as a dynamic library.
In any case, they will build the library and include it using their favourite build system. |
Sorry, I don't quite understand what you mean here. Is ZLIB just an example by itself, or you mean that KS runtime requiring zlib complicates things and dynamic library would help here in some way?
The problem with C++ is there is no really a clear way to "manage". In Linux and, to some extent, BSD, you have distribution packages which you can (in theory) rely on, but even here upgrading to a new verson of KS is not that trivial as just running In most other systems (OS X, Windows), it's much worse: there's no such magic as
This is irrelevant, this question is about whether loading large libraries with tons of unused functions would negatively affect code performance. Irrelevant as well, this has nothing to do with shared libraries. Slightly relevant, but majority of answers are far from reality. For example, no-one even mentions inlining, no-one even mentions LTO, etc.
Using OpenCV is typically a matter of calling a function that implements certain algorithm once. Using KS, little things like So, bottom line, before comitting to maintaining CMakeLists (and dynamic build at all) for this library, I would start with a solid benchmark, as suggested in kaitai-io/kaitai_struct#347.
|
There are useful configure files a client project can include the runtime project using
find_package
funcion.There is module to find iconv and include naturely.