-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
GDAL should not override POSITION_INDEPENDENT_CODE #5649
Comments
Is there a reason for having a separate override in each directory? |
There is already |
Well, if there are toolchains that pass compiler flags directly, then nothing can be done for these toolchains. |
Here: https://cmake.org/cmake/help/v3.23/variable/CMAKE_POSITION_INDEPENDENT_CODE.html |
I have added an |
I believe this PR is fine. We need to explicitly override CMake default settings because we use OBJECT libraries, that would otherwise be built with settings for static linking even if we incorporate them in a shared libraries (things could perhaps be simpler if we use features that were added in CMake 3.12 or 3.13 regarding linking an OBJECT library, but for now that's probably the best solution) |
I think that CMake documentation also shows that the use of this variable for executables somewhat changed with CMake versions/policies, so it has not only ON/OFF but also "unset". |
I indeed see in the doc that there might be potential issues with some linkers if enabling CMAKE_POSITION_INDEPENDENT_CODE for executables. @mmomtchev would you be willing to rework your PR to keep the various set_target_properties(), but perhaps use a GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE variable, initialized with BUILD_SHARED_LIBS value ? |
@rouault done |
fixed per #5650 |
Expected behavior and actual behavior.
Building GDAL as a static library and position independent code is currently very impractical
Every GDAL subdirectory includes a manual override:
POSITION_INDEPENDENT_CODE
should probably be a global value that can be adjusted by the user. My suggestion is that it be anoption
with its default value being${BUILD_SHARED_LIBS}
For example, when GDAL is being built as a Node.js addon it is built as a monolithic shared object - this means linking of the Node.js bindings application with a static GDAL build that must be position independent to be loaded into Node.js as a shared library.
GDAL version and provenance
GDAL 3.5.0-git
The text was updated successfully, but these errors were encountered: