CMake: Allow specifying a sysconfdir that's outside the prefix

Also use the value to actually write it into qconfig.cpp so that qmake
reports the right information.

Change-Id: Icc4bf36b0dc6ad75d93ac16f39e5b361c0ce52b4
Fixes: QTBUG-81289
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
bb10
Alexandru Croitor 2020-08-12 20:00:05 +02:00
parent 9e044765ec
commit 48dbcefe57
2 changed files with 18 additions and 11 deletions

View File

@ -26,10 +26,16 @@ function(qt_configure_process_path name default docstring)
# file(RELATIVE_PATH) returns an empty string if the given absolute paths are equal
set(rel_path ".")
elseif(rel_path MATCHES "^\.\./")
message(FATAL_ERROR
"Path component '${name}' is outside computed install prefix: ${rel_path} ")
# INSTALL_SYSCONFDIR is allowed to be outside the prefix.
if(NOT name STREQUAL "INSTALL_SYSCONFDIR")
message(FATAL_ERROR
"Path component '${name}' is outside computed install prefix: ${rel_path} ")
return()
endif()
set("${name}" "${${name}}" CACHE STRING "${docstring}" FORCE)
else()
set("${name}" "${rel_path}" CACHE STRING "${docstring}" FORCE)
endif()
set("${name}" "${rel_path}" CACHE STRING "${docstring}" FORCE)
endif()
endfunction()
@ -116,9 +122,14 @@ qt_configure_process_path(INSTALL_DATADIR "." "Arch-independent data [PREFIX]")
qt_configure_process_path(INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" "Documentation [DATADIR/doc]")
qt_configure_process_path(INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations"
"Translations [DATADIR/translations]")
if(APPLE)
set(QT_DEFAULT_SYS_CONF_DIR "/Library/Preferences/Qt")
else()
set(QT_DEFAULT_SYS_CONF_DIR "etc/xdg")
endif()
qt_configure_process_path(INSTALL_SYSCONFDIR
"etc/xdg"
"Settings used by Qt programs [PREFIX/etc/xdg]")
"${QT_DEFAULT_SYS_CONF_DIR}"
"Settings used by Qt programs [PREFIX/etc/xdg]/[/Library/Preferences/Qt]")
qt_configure_process_path(INSTALL_EXAMPLESDIR "examples" "Examples [PREFIX/examples]")
qt_configure_process_path(INSTALL_TESTSDIR "tests" "Tests [PREFIX/tests]")
qt_configure_process_path(INSTALL_DESCRIPTIONSDIR
@ -5830,11 +5841,7 @@ function(qt_generate_qconfig_cpp)
set(QT_CONFIG_STRS_SECOND "${QT_CONFIG_STRS}")
# Settings path / sysconf dir.
if(APPLE)
set(QT_DEFAULT_SYS_CONF_DIR "/Library/Preferences/Qt")
else()
set(QT_DEFAULT_SYS_CONF_DIR "etc/xdg")
endif()
set(QT_SYS_CONF_DIR "${INSTALL_SYSCONFDIR}")
# Compute and set relocation prefixes.
# TODO: Clean this up, there's a bunch of unrealistic assumptions here.

View File

@ -18,7 +18,7 @@ static const char qt_configure_strs[] =
@QT_CONFIG_STRS_SECOND@
#endif
;
#define QT_CONFIGURE_SETTINGS_PATH "@QT_DEFAULT_SYS_CONF_DIR@"
#define QT_CONFIGURE_SETTINGS_PATH "@QT_SYS_CONF_DIR@"
#define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@"
#define QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH@"
#define QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH@"