Skip to content

Commit

Permalink
Use qmake -query QT_INSTALL_PLUGINS to find install location
Browse files Browse the repository at this point in the history
Fallback for Qt 5.
  • Loading branch information
bjorn committed Jan 11, 2025
1 parent ad29c68 commit 132ae5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ jobs:
-DUSE_SHARED_ZLIB=on \
-DUSE_SHARED_PIXMAN=on \
-DUSE_SHARED_FREETYPE=on \
-DUSE_SHARED_HARFBUZZ=on \
-DQT_PLUGIN_PATH=`qmake -query QT_INSTALL_PLUGINS`
-DUSE_SHARED_HARFBUZZ=on
cmake --build build --config Release
sudo cmake --install build --config Release
Expand Down
29 changes: 12 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,22 @@ target_link_libraries(qaseprite
set(QT_PLUGIN_PATH "" CACHE STRING "Install location for Qt plugins")

if(NOT QT_PLUGIN_PATH)
set(QT_INSTALL_PREFIX ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX})
set(QT_INSTALL_PLUGINS ${QT${QT_VERSION_MAJOR}_INSTALL_PLUGINS})

if(DEFINED ENV{QT_PLUGIN_PATH})
set(QT_PLUGIN_PATH $ENV{QT_PLUGIN_PATH})
elseif(QT_INSTALL_PREFIX AND QT_INSTALL_PLUGINS)
set(QT_PLUGIN_PATH "${QT_INSTALL_PREFIX}/${QT_INSTALL_PLUGINS}")
else()
set(QT_INSTALL_PREFIX ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX})
set(QT_INSTALL_PLUGINS ${QT${QT_VERSION_MAJOR}_INSTALL_PLUGINS})

# If QT_INSTALL_PREFIX is empty, try to derive it from QT_DIR, cutting off the
# last three components ("lib/cmake/Qt5") from the path
if(NOT QT_INSTALL_PREFIX)
set(QT_INSTALL_PREFIX ${QT_DIR})
get_filename_component(QT_INSTALL_PREFIX ${QT_INSTALL_PREFIX} DIRECTORY)
get_filename_component(QT_INSTALL_PREFIX ${QT_INSTALL_PREFIX} DIRECTORY)
get_filename_component(QT_INSTALL_PREFIX ${QT_INSTALL_PREFIX} DIRECTORY)
find_program(QT_QMAKE_EXECUTABLE NAMES "qmake" "qmake-qt5" "qmake.exe")
if(QT_QMAKE_EXECUTABLE)
execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" "-query" "QT_INSTALL_PLUGINS"
OUTPUT_VARIABLE QT_PLUGIN_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
message(FATAL_ERROR "Cannot find qmake executable")
endif()

# If QT_INSTALL_PLUGINS is empty, set it to "plugins"
if(NOT QT_INSTALL_PLUGINS)
set(QT_INSTALL_PLUGINS "plugins")
endif()

set(QT_PLUGIN_PATH "${QT_INSTALL_PREFIX}/${QT_INSTALL_PLUGINS}")
endif()
set(QT_PLUGIN_PATH "${QT_PLUGIN_PATH}" CACHE STRING "Install location for Qt plugins" FORCE)
endif()
Expand Down

0 comments on commit 132ae5a

Please sign in to comment.