Each component can now be built and installed separately
8 unresolved threads
8 unresolved threads
Compare changes
Files
7+ 15
− 1
@@ -11,7 +11,21 @@
The implementation allowed for separate building and installation of all the components, enhancing efficiency and modularity
Created separate target files for individual components; also added new CMake options to enable the building of individual components.
Fixed an issue with the 'libiconmath' package not being found in another program when it is installed in a custom prefix directory.
Additionally, two more major changes were made:
iconmath
. The motivation behind the change was that I found a code that uses a module from iconmath::horizontal
compiles fine even though that component is not linked using target_link_libraries
.iconmath
. Before, the inclusions of components interpolation
and horizontal
were done depending on their presence in the proper place. But, because of this, it was possible to use target_link_libraries(new-project PRIVATE iconmath::horizontal)
successfully even when iconmath
was found using find_package(iconmath CONFIG REQUIRED COMPONENTS interpolation)
. This should always give an error, which was not the case before these changes were made.make format
for linting)
Draft:
You are not supposed to merge this request by yourself, the maintainers of libiconmath take care of this action!
Why do we need separate
targets
files for the components?I thought that each component must have its own target file. That's why I started to make these changes. It makes sense to me, as it helps all the components be managed independently. Although it is a small project now, it has the possibility to grow, and then having smaller target files for each component will also scale well. I am not sure what the benefits of having just one target file for all components are other than that it will be simpler.
Yes, it will be simpler. What are the benefits of having multiple target files?
Each component has its own directory, 'cmake' configuration, and binary file. I do not see how having its target file breaks the deal. For me, it is still part of the modular structure upon which the library is built, and enough reason to have it this way.
But still, I would like to discuss a problem which could be solved by having three
targets
. I already mentioned aCMakeLists.txt
file in one of my earlier comments in this MR. It is:I think you will agree that this should produce an error during the configuration, mainly because it only asks for the component
interpolation
and its dependencies at thefind_package
step. Still, later, it is trying to link thehorizontal
component (one should not be just lucky about it). But, with one target file and assumingiconmath
with all of its components being already installed, this does configure without any error. Actually, it was still possible to configure it without failing, even with three target files, till I corrected it in (this)[!5 (e4dfd148)] commit. Do you see that as a benefit? I can not think of an alternative but elegant solution for this, which could be my lack of understanding of CMake.The "modular structure" is not an absolute good but a tradeoff with the usual benefit of improved maintainability. Changes in this particular file do not look like they make the code more maintainable. Simply because a single target file does not need any extra code to maintain.
I am sorry but you are starting with a wrong assumption. The users are free to do whatever they want in their scripts (believe it or not, sometimes the reason for that is that they know better). We are only supposed to deliver the interface: the user requests a component - we define the respective target (or fail if the target is not available but
REQUIRED
). We are free to define more targets, functions and variables but those are implementation details. If the users rely onhorizontal
being available when onlyinterpolation
is requested, it's their problem. This might break at some point and will need a fix, which will be to explicitly requesthorizontal
as well.