Skip to content

Commit

Permalink
CMake: Install to QT_PLUGIN_PATH when set in environment
Browse files Browse the repository at this point in the history
Provides a workaround for issue #2.
  • Loading branch information
bjorn committed Jan 10, 2025
1 parent a6ba5db commit da15f52
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,30 @@ target_link_libraries(qaseprite
dio-lib
render-lib)

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})
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)
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()

install(
TARGETS qaseprite
RUNTIME DESTINATION "${QT_INSTALL_PREFIX}/${QT_INSTALL_PLUGINS}/imageformats"
LIBRARY DESTINATION "${QT_INSTALL_PREFIX}/${QT_INSTALL_PLUGINS}/imageformats")
RUNTIME DESTINATION "${QT_PLUGIN_PATH}/imageformats"
LIBRARY DESTINATION "${QT_PLUGIN_PATH}/imageformats")

0 comments on commit da15f52

Please sign in to comment.