Skip to content

[Bug] CMake with FHS tries to create a directory outside build on configure #5432

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

Open
HuidaeCho opened this issue Mar 22, 2025 · 2 comments
Labels
CMake enhancement New feature or request
Milestone

Comments

@HuidaeCho
Copy link
Member

cmake .. -DWITH_FHS=ON tries to create /usr/local/libexec/grass/gui/wxpython on configuring before make install:

file(MAKE_DIRECTORY "${GISBASE}/gui/wxpython")

GISBASE is set here (CMAKE_INSTALL_PREFIX=/usr/local for UNIX [1]):

set(GISBASE ${CMAKE_INSTALL_PREFIX}/${GISBASE_DIR})
set(RUNTIME_GISBASE "${OUTDIR}/${GISBASE_DIR}")

RUNTIME_GISBASE (not clear why it's called "runtime") is created in the build output directory, which is fine. I think we should create any directories or files outside the build directory only on installation.

@HuidaeCho HuidaeCho added enhancement New feature or request CMake labels Mar 22, 2025
@HuidaeCho HuidaeCho changed the title [Bug?] cmake .. -DWITH_FHS=ON tries to create a directory in /usr/local [Bug] cmake .. -DWITH_FHS=ON tries to create a directory in /usr/local Mar 22, 2025
@HuidaeCho HuidaeCho changed the title [Bug] cmake .. -DWITH_FHS=ON tries to create a directory in /usr/local [Bug] CMake with FHS tries to create a directory outside build on configure Mar 22, 2025
@nilason
Copy link
Contributor

nilason commented Mar 24, 2025

Glad to see you reached so far as to test FHS! :-) I haven't, since I left over the baton a year ago.

There are a number of hard coded links (relative to GISBASE) to files/directories in code, which I didn't want to address at that time.

It may look like:

snprintf(path, GPATH_MAX, "%s/etc/colors.desc", G_gisbase());

The whole block you refer to was a temporary hack to "get thing moving" at the time:

grass/CMakeLists.txt

Lines 175 to 194 in 18e0846

# TODO: a proper fix to this workaround
if(WITH_FHS)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_DEMODIR}
${RUNTIME_GISBASE}/demolocation SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_FONTSDIR} ${RUNTIME_GISBASE}/fonts
SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/colors
${RUNTIME_GISBASE}/etc/colors SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/colors.desc
${RUNTIME_GISBASE}/etc/colors.desc SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/element_list
${RUNTIME_GISBASE}/etc/element_list SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/renamed_options
${RUNTIME_GISBASE}/etc/renamed_options SYMBOLIC)
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/VERSIONNUMBER
${RUNTIME_GISBASE}/etc/VERSIONNUMBER SYMBOLIC)
file(MAKE_DIRECTORY "${GISBASE}/gui/wxpython")
file(CREATE_LINK ${OUTDIR}/${GRASS_INSTALL_GUIDIR}/wxpython/xml
${RUNTIME_GISBASE}/gui/wxpython/xml SYMBOLIC)
endif()

The files/directories are with FHS located elsewhere, and this we need to address in code. They are $GISBASE +

  • demolocation
  • fonts
  • etc/colors
  • etc/color.desc
  • etc/element_list
  • etc/renamed_option
  • etc/VERSIONNUMBER
  • gui/wxpython/xml

I'm now sure how to best address this to account for both current system and the FHS, but the time has come for us to find a solution.

(RUNTIME_GISBASE refers to the GISBASE in the build stage, which is needed because grass is running in parts of the building process, generating docs etc, but also to facilitate the possibility to test without installing. The choice of prefixing with "RUNTIME" is not carved in stone and may be reconsidered.)

@nilason nilason added this to the 8.5.0 milestone Mar 24, 2025
@nilason
Copy link
Contributor

nilason commented Mar 24, 2025

I'm now sure how to best address this to account for both current system and the FHS, but the time has come for us to find a solution.

Perhaps we can introduce another environment variable: e.g., GRASS_SHARE_DIR, which under FHS is /usr/share/grass and under current system equals (for these elements) GISBASE (see #3661 (comment))

  • demolocation may be found under $GRASS_SHARE_DIR/demolocation
  • etc/element_list under $GRASS_SHARE_DIR/etc/element_list
    ... etc.

Which in practice could look like:

 snprintf(path, GPATH_MAX, "%s/etc/colors.desc", G_grass_share_dir()); 

gui/wxpython/xml will need another approach, depending on how we deal with Python code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants