Structure Libtcod Project #79
Replies: 7 comments
-
Moving the headers to their own include directory might help with organization but I don't see how it affects CPM. This probably continues off our previous conversations on the topic of CMake and the build tools in general: #64 #66 I don't think I have a good setup to do make installs right now and that might be affecting my ability to work with CMake properly. Right now I'm mostly stuck with using the CMake Tools extension for Visual Studio Code to build and test the library. Which works well with Vcpkg but when I tried to switch to CPM for dependency management I had issues with linking SDL2 at runtime. Libtcod's headers were detected at that time, at least to compile it and its samples. At this point I'd be fine with breaking Conan builds/tests to add CPM support, when I wasn't before. |
Beta Was this translation helpful? Give feedback.
-
It does not affect CPM, it affects projects using Libtcod, why, as a first point: it populates the Target with scattered headers, the goal is to contain the API within a directory (for example: I am aware that perhaps the last two points exposed are irrelevant, since there is a version of Libtcod for Python and the use of Cling requires compiling the project with Clang. .... Libtcod is a library, not an executable, you should not use a dependency manager because you will end up creating an ODR (One Definition Rule)1 See the problem: matplotplusplus. The dependencies that I have in mind at the moment in Libtcod are SDL, SDL2, libpng, libz. All of these can be located and linked with CMake and should not be downloaded as dependencies for a library. Therefore it is totally invalid to use Vcpk, Conan or any other program or script to obtain these dependencies, instead these tools should be used to obtain Libtcod and it will be the user's responsibility to provide the necessary libraries to make Libtcod work. |
Beta Was this translation helpful? Give feedback.
-
The ODR violations seem to come from vendored dependencies. Libtcod's vendored libraries are GLAD, lodepng, utf8proc, and stb. These would all need to be unvendored to prevent possible conflicts. Libtcod is often used by people as their first library, so my requirements for the ease-of-use of installing it are very high. I can't rely on people being able to install libtcod's dependencies manually on all platforms. vcpkg and Conan already handle libtcod and its dependencies by themselves. CPM should be able to do the same, or else it's less useful than the previous two for newer developers, and therefore less useful to me as the whole point was to make things easier for others to setup. What I'm looking for is the ability to compile a hello-world program using only CMake, Git, the local compiler, an Internet connection, and no further experience. With the steps to build the project being to clone the hello-world repository and invoke CPM/CMake. I already have a Conan/CMake example of this, but setting up Conan or Vcpkg is still quite a process so anything which takes fewer steps is better. |
Beta Was this translation helpful? Give feedback.
-
I think it's an incredible idea, but you're leading it by the wrong path (in my opinion), if what you're looking for is to reduce the steps to compile and run a program, Conan, Vcpkg and any other dependency manager won't do it, because you have to start from the fact, that to use them, you need to download and install those package managers, with this you already increase the requirements to compile and run [the examples of] Libtcod.
|
Beta Was this translation helpful? Give feedback.
-
The things I consider the most user-error prone would be running commands from the command-line and adding compiler/linker flags. I hoped that I could use CMake/CPM to reduce everything to one command and a small CMake script. It could be that I'm asking for the impossible and that I can only get the kind of setup I want outside of C/C++. In that case I can only really setup my CMake scripts for package maintainers like in the CppCon video you linked to. |
Beta Was this translation helpful? Give feedback.
-
I don't know how to install libraries like SDL2 and GLAD under Windows using commands, but in a Linux-based distribution, the use of commands is the easiest way to install a package or a program. I don't consider, that executing commands is an action prone to errors by the user, by this way, maybe we have a chance.
I agree with you in this section, this if it can be an action prone to errors on the part of the user, with a good configuration, would not have to request the user to carry out this type of options. In my opinion, the only commands that the user should perform, would be, the installation of at least one Backend (SDL, GLAD, SFML, etc ...) and the Libtcod compilation commands, of the remaining dependencies, you could take the option to embed them and on the configuration, CMake was designed for that. |
Beta Was this translation helpful? Give feedback.
-
If you're coming from a Linux background then that explains why you've talked about installing dependencies as if it were trivial. All of the Linux package managers make installing dependencies a breeze, but trying to setup any library on Windows is a huge pain. MacOS at least has Brew which is often as good as a Linux package manager. Microsoft's most equivalent tool to using Linux package manger for development is Vcpkg. An alternative to that is MSYS, but MSYS doesn't mesh very well with other Windows tools. If I was targeting just Linux/MacOS then I could have set things up exactly how you described, with CMake only checking for system packages rather than having to try and download anything itself. I'm expecting any hypothetical new developers to be either coming from Windows or at least wanting to target Windows. GLAD isn't like other packages. You ask for which parts of the OpenGL API you want and get a custom module for it. I might have been getting confused about what violates the ODR. If those issues can be avoided with careful omissions of dllexport and default visibility then I don't think I'll have many issues. I think I'm starting to get a more clear picture of how I could set this up. |
Beta Was this translation helpful? Give feedback.
-
A good project structure will allow you to use CPM (Content Package Manager) to download Libtcod and configure it without the need to install it on your system.
The steps to perform would be to move the .h/hpp files to a new directory, as indicated here.
Beta Was this translation helpful? Give feedback.
All reactions