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

Added additional directory to QT_TRANSLATIONS_DIR search #6

Closed
wants to merge 1 commit into from
Closed

Added additional directory to QT_TRANSLATIONS_DIR search #6

wants to merge 1 commit into from

Conversation

exploide
Copy link

This adds the directory /usr/share/qt5/translations to the list of tested directories when searching the correct value for QT_TRANSLATIONS_DIR. This fixes the build on RedHat-based Linux distributions like Fedora.

…or QT_TRANSLATIONS_DIR

fixes compilation on RedHat-based Linux distributions (i.e. Fedora)
@CLAassistant
Copy link

CLAassistant commented Dec 29, 2017

CLA assistant check
All committers have signed the CLA.

@exploide
Copy link
Author

While Travis is complaining, it looks like this is unrelated to my changes but something with the setup of the packages within Travis' container.

@tuxmaster
Copy link

Or use:
cmake -DQT_TRANSLATIONS_DIR=$(qmake-qt5 -query QT_INSTALL_TRANSLATIONS)
in the .spec file

@exploide
Copy link
Author

exploide commented Dec 30, 2017

Specifying -DQT_TRANSLATIONS_DIR on command line was my first workaround, but I consider it cleaner if it just works out of the box like it does on other platforms. Especially because someone without prior QT knowledge needs some time to figure out what is needed.

@misery
Copy link
Contributor

misery commented Dec 30, 2017

Thank you very much! I will look into it soon.
Travis had an i/o issue... I restarted the build job.

@misery misery self-assigned this Dec 30, 2017
@misery
Copy link
Contributor

misery commented Jan 2, 2018

Ok, I looked into it.
Why is it necessary to add hardcoded "/usr/..."? It should be detected by "${QT_HOST_PREFIX}/share/qt5", too.

Maybe QT_HOST_PREFIX / _qt5Core_install_prefix is undefined? What is the value of the variable?
Do you have a correct "Qt5CoreConfig.cmake" on your system?

@exploide
Copy link
Author

exploide commented Jan 2, 2018

Ah, that's because on the targeted system it is QT_HOST_PREFIX: /usr/lib64/qt5. It seems on RedHat/Fedora systems, Qt is split into at least two directories:

> ls -l /usr/lib64/qt5
insgesamt 32
drwxr-xr-x.  2 root root  4096 29. Dez 15:37 bin/
drwxr-xr-x.  2 root root  4096 30. Nov 10:10 imports/
drwxr-xr-x.  2 root root  4096 30. Nov 10:10 libexec/
drwxr-xr-x. 64 root root  4096 20. Dez 11:28 mkspecs/
drwxr-xr-x. 50 root root 12288 29. Dez 15:08 plugins/
drwxr-xr-x. 22 root root  4096 29. Dez 15:08 qml/

> ls -l /usr/share/qt5
insgesamt 28
drwxr-xr-x. 2 root root  4096 29. Dez 14:03 phrasebooks/
-rw-r--r--. 1 root root    56 30. Nov 09:45 qtlogging.ini
drwxr-xr-x. 2 root root 20480 29. Dez 14:11 translations/

@misery
Copy link
Contributor

misery commented Jan 2, 2018

Ok, thanks! Could you try this patch?
I do not like hardcoded stuff. :-) So I would add this as a fix for your issue. Also it should be more flexible if another distribution uses another style. ;-)

diff --git a/cmake/Helper.cmake b/cmake/Helper.cmake
--- a/cmake/Helper.cmake
+++ b/cmake/Helper.cmake
@@ -54,6 +54,25 @@ FUNCTION(ADD_FLAG)
 ENDFUNCTION()
 
 
+FUNCTION(QUERY_QMAKE _out _var)
+       IF(NOT TARGET Qt5::qmake)
+               MESSAGE(WARNING "qmake not found")
+               RETURN()
+       ENDIF()
+
+       GET_TARGET_PROPERTY(qmake_bin Qt5::qmake LOCATION)
+       EXECUTE_PROCESS(COMMAND "${qmake_bin}" -query ${_var}
+               RESULT_VARIABLE _result
+               OUTPUT_VARIABLE _output
+               ERROR_QUIET
+               OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+       IF(_result EQUAL 0)
+               SET(${_out} "${_output}" PARENT_SCOPE)
+       ENDIF()
+ENDFUNCTION()
+
+
 FUNCTION(GET_FILE_MATCHER _result_remove _result_keep)
        IF(NOT ANDROID)
                LIST(APPEND matcher_remove "_android")
diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake
--- a/cmake/Libraries.cmake
+++ b/cmake/Libraries.cmake
@@ -44,6 +44,10 @@ FOREACH(dest "" "share/qt" "share/qt5")
        ENDIF()
 ENDFOREACH()
 
+IF(NOT QT_TRANSLATIONS_DIR)
+       QUERY_QMAKE(QT_TRANSLATIONS_DIR QT_INSTALL_TRANSLATIONS)
+ENDIF()
+
 MESSAGE(STATUS "QT_HOST_PREFIX: ${QT_HOST_PREFIX}")
 MESSAGE(STATUS "QT_TRANSLATIONS_DIR: ${QT_TRANSLATIONS_DIR}")
 

@exploide
Copy link
Author

exploide commented Jan 2, 2018

Yes, it works. This is a good idea.

@misery
Copy link
Contributor

misery commented Jan 3, 2018

Ok, it will be included in next release. :-)

@misery misery closed this Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants