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

Allow QT_PLUGIN_PATH to be set as CMake parameter #11

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,29 @@ target_link_libraries(qaseprite
dio-lib
render-lib)

if(DEFINED ENV{QT_PLUGIN_PATH})
set(QT_PLUGIN_PATH $ENV{QT_PLUGIN_PATH})
else()
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 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)
endif()

# If QT_INSTALL_PLUGINS is empty, set it to "plugins"
if(NOT QT_INSTALL_PLUGINS)
set(QT_INSTALL_PLUGINS "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()
if(NOT QT_QMAKE_EXECUTABLE)
find_program(QT_QMAKE_EXECUTABLE NAMES "qmake" "qmake-qt5" "qmake.exe")
endif()
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()
endif()

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

install(
Expand Down