Skip to content
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

Use GNUInstallDirs for cmake install locations #3150

Merged
merged 9 commits into from
Apr 7, 2022

Conversation

ErixenCruz
Copy link
Contributor

@ErixenCruz ErixenCruz commented Mar 29, 2022

Changes to the CMAKE build system to use GNUInstallDirs for installation locations. I only tested this on Ubuntu. Would someone verify that this is fine on Windows and Mac, too?

@ErixenCruz ErixenCruz marked this pull request as draft March 29, 2022 19:39
@mwtoews
Copy link
Member

mwtoews commented Mar 29, 2022

There are some issues generating a proj.pc file for pkg-config, but otherwise this looks good so far!

@ErixenCruz ErixenCruz marked this pull request as ready for review March 31, 2022 18:43
@ErixenCruz
Copy link
Contributor Author

Thanks @mwtoews proj.pc should be good now. I think this is ready for review.

@ErixenCruz
Copy link
Contributor Author

Ah apparently not. The problem for the Linux build seems to be moving the include directory somewhere else. I will explore /~https://github.com/nektos/act to be able to run the Github actions locally instead of pushing and waiting for it to fail.

@mwtoews
Copy link
Member

mwtoews commented Mar 31, 2022

I suppose the issue is around here:

PROJ/travis/install.sh

Lines 156 to 162 in b1d2fcb

sed -i'.bak' -e '1c\
prefix='"$INST"'/proj_shared_install_from_dist_renamed/subdir' $INST/proj_shared_install_from_dist_renamed/subdir/lib/pkgconfig/proj.pc
# cat $INST/proj_shared_install_from_dist_renamed/subdir/lib/pkgconfig/proj.pc
sed -i'.bak' -e '1c\
prefix=/tmp/proj_static_install_from_dist_renamed/subdir' /tmp/proj_static_install_from_dist_renamed/subdir/lib/pkgconfig/proj.pc
# cat /tmp/proj_static_install_from_dist_renamed/subdir/lib/pkgconfig/proj.pc

this assumes there is only one prefix at the top of proj.pc to change on the first line (1c). You could use sed differently to replace each line that matches the contents of the original path with the moved path. Be aware that there are different versions of sed on the runners, so that macOS have different options than on (e.g.) Ubuntu. Also, I noticed that exec_prefix could be removed from the template, since it's no longer needed in this revision.

@mwtoews
Copy link
Member

mwtoews commented Apr 1, 2022

The macOS failure because the executables are installed to:

-- Installing: /tmp/proj_static_install_from_dist/Applications/OSGEO/projinfo

due to set(CMAKE_INSTALL_BINDIR ${BUNDLEDIR}) in cmake/ProjMac.cmake. The logic doesn't seem right before, as this variable is set no matter the configuration of BUILD_FRAMEWORKS_AND_BUNDLE. Perhaps add a seperate if(BUILD_FRAMEWORKS_AND_BUNDLE) block to set this variable. I'm not even sure if anyone actually uses this CMake option, and am tempted to delete cmake/ProjMac.cmake altogether someday.

@ErixenCruz
Copy link
Contributor Author

Ok I have wrapped the variable setting inside that condition. No Mac to test on, but hopefully the Mac build Github action is good now.

Copy link
Member

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks excellent, and I can't see any obvious issues. Anyone else have a chance to review? Otherwise I'll merge this in a few days. Note that this should not be backported.

Comment on lines 14 to 16
set (@PROJECT_VARIANT_NAME@_INCLUDE_DIRS ${CMAKE_INSTALL_INCLUDEDIR})
set (@PROJECT_VARIANT_NAME@_LIBRARY_DIRS ${CMAKE_INSTALL_LIBDIR})
set (@PROJECT_VARIANT_NAME@_BINARY_DIRS ${CMAKE_INSTALL_BINDIR})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should rather be:

Suggested change
set (@PROJECT_VARIANT_NAME@_INCLUDE_DIRS ${CMAKE_INSTALL_INCLUDEDIR})
set (@PROJECT_VARIANT_NAME@_LIBRARY_DIRS ${CMAKE_INSTALL_LIBDIR})
set (@PROJECT_VARIANT_NAME@_BINARY_DIRS ${CMAKE_INSTALL_BINDIR})
set (@PROJECT_VARIANT_NAME@_INCLUDE_DIRS "${_ROOT}/@CMAKE_INSTALL_INCLUDEDIR@")
set (@PROJECT_VARIANT_NAME@_LIBRARY_DIRS "${_ROOT}/@CMAKE_INSTALL_LIBDIR@")
set (@PROJECT_VARIANT_NAME@_BINARY_DIRS "${_ROOT}/@CMAKE_INSTALL_BINDIR@")

as _ROOT must remain referenced

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_INSTALL_<dir> are relative paths, meant to be used with install( ... DESTINATION ...).

For absolute paths, there is CMAKE_INSTALL_FULL_<dir>. This takes into account CMAKE_INSTALL_PREFIX (but breaks CMAKE_STAGING_PREFIX).

Now what is _ROOT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which do we think it should be? I think it is wrong the way it is, too.

If these variables should be the include, library, and binary directories of install, then the FULL variables from GNUInstallDirs will do fine as @dg0yt says I think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now what is _ROOT?

As far as I can see, this is a way to figure out the (actual) installation prefix from where the CMake config file is located.

If these variables should be the include, library, and binary directories of install, then the FULL variables from GNUInstallDirs will do fine

yeah that was my first thought too. But it seems the existing logic in the file was to make it possibly relocatable. And I hope that what I proposed would make it still possible

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed part of the context. Basically @rouault is right, and I see where _ROOT comes from now.

I will test the PR in the next days.

@@ -101,5 +101,5 @@ set(ALL_DATA_FILE
)
install(
FILES ${ALL_DATA_FILE}
DESTINATION ${DATADIR}
DESTINATION ${PROJ_LIB_PATH}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but this looks strange.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's after PROJ_LIB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming isn't straightforward. In the context of cmake, this implies the library install path I think, though we know what PROJ_LIB means outside of cmake (the link above was what I was thinking of when I named it). What's the best name for this? DATADIR isn't too clear either

set(CMAKECONFIGDIR "${DEFAULT_CMAKEDIR}"
CACHE PATH "Parent of the directory to install cmake config files into.")
include(GNUInstallDirs)
set(PROJ_LIB_PATH "${CMAKE_INSTALL_FULL_DATADIR}/proj")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that's not the best name for data.

@thesamesam
Copy link

Just wanted to say thanks for this!

Copy link

@thesamesam thesamesam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a PROJ developer but I am a maintainer of it downstream (in Gentoo) and occasional contributor. Also used to doing GNUInstallDirs ports. Looks great, thanks!

include/proj/CMakeLists.txt Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
@mwtoews
Copy link
Member

mwtoews commented Apr 7, 2022

Thanks again @ErixenCruz for putting this together!

@mwtoews mwtoews merged commit b7b89e7 into OSGeo:master Apr 7, 2022
@ErixenCruz ErixenCruz deleted the use-gnu-install-dirs branch April 11, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants