Skip to content

Commit

Permalink
[Github CI] Fix missing package on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
christianparpart committed Nov 20, 2023
1 parent 57e6c86 commit 13cce6e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ jobs:
cmake . \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCONTOUR_TESTING=ON \
-DQt${QTVER}_DIR="$(brew --prefix qt@${QTVER})/lib/cmake/Qt${QTVER}" \
-DCMAKE_PREFIX_PATH$="$(brew --prefix qt@${QTVER})" \
-DCONTOUR_QT_VERSION=${QTVER} \
-B build/
- name: "Build"
Expand Down
3 changes: 2 additions & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ fi
case "$OSTYPE" in
darwin*)
if test v$QTVER = v6; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DQt6_DIR=$(brew --prefix qt6)/lib/cmake/Qt6"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DCMAKE_PREFIX_PATH=$(brew --prefix qt@6)"
#EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DQt6_DIR=$(brew --prefix qt6)/lib/cmake/Qt6"
#EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DQt6_DIR=$HOME/Qt/6.5.3/macos/lib/cmake/Qt6"
else
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5"
Expand Down
61 changes: 26 additions & 35 deletions src/contour/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ if(CONTOUR_FRONTEND_GUI)
Qt6::Network
Qt6::OpenGL
Qt6::Qml
Qt6::QuickControls2
Qt6::Widgets
)
if(NOT(WIN32) AND NOT(APPLE))
Expand Down Expand Up @@ -304,13 +305,18 @@ endfunction()
# endif(APPLE)

macro(bundle_install_qt_plugin _qt_plugin_name _qt_plugins_var)
# Qt6 provides the plugins as individual packages that need to be found.
set(_install_prefix "contour.app/Contents/")
find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET PATHS ${Qt${INSTALLED_QT_VERSION}${_qtComponent}_DIR})
if(TARGET "${_qt_plugin_name}")
get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION)
else()
_qt_get_plugin_name_with_version("Qt::${_qt_plugin_name}" _qt_plugin_with_version_name)
if(TARGET "${_qt_plugin_with_version_name}")
get_target_property(_qt_plugin_path "${_qt_plugin_with_version_name}" LOCATION)
else()
message(STATUS "Qt ${_qt_plugin_name}: Ignoring")
return()
endif()
endif()
if(EXISTS "${_qt_plugin_path}")
Expand All @@ -321,39 +327,34 @@ macro(bundle_install_qt_plugin _qt_plugin_name _qt_plugins_var)
if("${_qt_plugin_ext}" STREQUAL ".dylib")
set(_qt_plugin_dir "PlugIns")
set(_qt_plugin_dest "${_install_prefix}${_qt_plugin_dir}/${_qt_plugin_type}")
message(STATUS "Install Qt plugin: ${_qt_plugin_path} ~> ${_qt_plugin_dest}")
message(STATUS "Qt ${_qt_plugin_name}: Installing from ${_qt_plugin_path}")
install(FILES "${_qt_plugin_path}" DESTINATION "${_qt_plugin_dest}")
set(${_qt_plugins_var} "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}")
else()
message(STATUS "bundle_install_qt_plugin: Ignoring '${_qt_plugin_path}'")
message(STATUS "Qt ${_qt_plugin_name}: Ignoring '${_qt_plugin_path}'")
endif()
endif()
endmacro()

# _qtComponents - in-variable name, list of Qt components (like Gui, Qml, Widgets) to install
# _plugins_var - out-variable name, list variable that will contain all the libraries to maybe carry over
macro(bundle_install_all_qt_plugins _qtComponents _plugins_var)
foreach(_qt_comp IN LISTS ${_qtComponents})
if(INSTALLED_QT_VERSION VERSION_LESS 6)
set(_qt_module_plugins ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_PLUGINS})
else()
get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qt_comp} QT_PLUGINS)
endif()
macro(bundle_install_qt_plugins_for_component _qtComponent _plugins_var)
get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qtComponent} ${_plugins_var})
if(NOT _qt_module_plugins)
message(STATUS "Qt ${_qtComponent}: no plugins to install")
else()
message(STATUS "Qt ${_qtComponent}: collecting ...")
foreach(_qt_plugin IN LISTS _qt_module_plugins)
if(INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6)
# Qt6 provides the plugins as individual packages that need to be found.
find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET PATHS ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_DIR})
endif()
bundle_install_qt_plugin("${_qt_plugin}" "${_plugins_var}")
endforeach()
endforeach()
endif()
endmacro()

get_property(_Qt_Core_LOCATION TARGET Qt${INSTALLED_QT_VERSION}::Core PROPERTY LOCATION)
get_filename_component(Qt_BIN_DIR "${_Qt_Core_LOCATION}" PATH)
if(APPLE)
get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH)
endif()
# get_property(_Qt_Core_LOCATION TARGET Qt${INSTALLED_QT_VERSION}::Core PROPERTY LOCATION)
# get_filename_component(Qt_BIN_DIR "${_Qt_Core_LOCATION}" PATH)
# if(APPLE)
# get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH)
# endif()
# }}}

if(WIN32)
Expand Down Expand Up @@ -395,7 +396,9 @@ elseif(APPLE)

# NB: This is mostly based on code from CMake's QtDialog/CMakeLists.txt
# TODO: Minimize the number of plugins installed to the required ones.
bundle_install_all_qt_plugins(QT_COMPONENTS QT_PLUGINS)
foreach(_qt_comp IN LISTS QT_COMPONENTS)
bundle_install_qt_plugins_for_component("${_qt_comp}" QT_PLUGINS)
endforeach()

# Install application icon
install(FILES "res/images/contour-logo.icns" DESTINATION "${INSTALL_CMAKE_DIR}" RENAME "contour.icns")
Expand Down Expand Up @@ -438,6 +441,8 @@ elseif(APPLE)
endif()

# some debug printing
list(SORT QT_PLUGINS)
list(REMOVE_DUPLICATES QT_PLUGINS)
foreach(_plugin ${QT_PLUGINS})
message(STATUS "Qt Plugin: ${_plugin}")
endforeach()
Expand All @@ -450,21 +455,7 @@ elseif(APPLE)
include(DeployQt) # Just to get access to ${MACDEPLOYQT_EXECUTABLE}
get_filename_component(_macdeployqt_path "${MACDEPLOYQT_EXECUTABLE}" PATH)
message(STATUS "macdeployqt path: ${_macdeployqt_path}")
message(STATUS "macdeployqt location : ${MACDEPLOYQT_EXECUTABLE}")

set(QT_PLUGINS_DIR "${Qt6Widgets_DIR}/../../../plugins")
set(QT_QML_PLUGINS_DIR "${Qt6Widgets_DIR}/../../../qml")

set(qtconf_dest_dir "${BUNDLE_APP}/Contents/Resources")
set(plugin_dest_dir "${BUNDLE_APP}/Contents/PlugIns")
set(qml_dest_dir "${BUNDLE_APP}/Contents/Resources/qml")

# If we are in a dynamic build of qt
if(EXISTS "${QT_PLUGINS_DIR}/platforms/libqcocoa.dylib")
install(FILES "${QT_PLUGINS_DIR}/platforms/libqcocoa.dylib" DESTINATION "${plugin_dest_dir}/platforms")
install(FILES "${QT_PLUGINS_DIR}/imageformats/libqsvg.dylib" DESTINATION "${plugin_dest_dir}/imageformats")
install(FILES "${QT_PLUGINS_DIR}/iconengines/libqsvgicon.dylib" DESTINATION "${plugin_dest_dir}/iconengines")
endif()
message(STATUS "macdeployqt location: ${MACDEPLOYQT_EXECUTABLE}")

install(CODE "
execute_process(
Expand Down

0 comments on commit 13cce6e

Please sign in to comment.