Closed francesco-bosia closed 5 years ago
Thanks for the contribution!
Due to (mostly trivial, but nonzero) impact of PIC on performance it is desirable to be able to avoid PIC when not required. Hence the default behavior to produce a single (shared or static) library, with its type specified by BUILD_SHARED_LIBS
(user can already produce a dynamic library by setting this cache variable via command line or ccmake). I recommend the proposed 1-shot shared+static build is made optional, enabled by cache variable LIBINT_BUILD_SHARED_AND_STATIC_LIBS
(or smth similar).
Thoughts?
Thank you for your review!
I get your point. I did not profile the code with and without PIC, so I will adapt the pull request to implement the proposal for optional one-shot construction of shared and static libraries.
I highly doubt that the performance impact is significant, if any. Nevertheless I prefer to "only pay for what you use".
Ok. Then I will remove the PIC and allow for 1 shot static and shared build.
I tried to grep the whole CMake project for BUILD_SHARED_LIBS
or SHARED
, but I did not find where the option is set/used. Could you please point me to where the option is set/used in the CMake project?
Sure! I changed the CMakeLists.txt.export to include the cases in which both libraries are constructed and the case where only a specific library is constructed accordingly.
Some tests fail due to timeouts.
Currently, in the cmake project, only a static library is produced (libint2.a). This library is compiled without setting the position independent code property to
ON
. This prevents the subsequent linking of the library in a shared library.I did it in my local repo, but I thought to spread my solution with the project.
In order to do so, I propose to a) add the said property (
set_target_property PROPERTIES POSITION_INDEPENDENT_CODE ON
) to the obejct file produced for theint2
library. b) produce a shared and a static version of the libraries without increasing the compile time. This is done by compiling an object fileint2_obj
and subsequently creating aSTATIC
int2_static
and aSHARED
int2
target form it. Compile time is thus the same.Now both versions are available for linking. No further problem with shared projects is envisioned. Tests are linked to the shared version to save some time at link stage.