forked from qt-creator/qt-creator
CMake Deployment: Move creation of qt.conf to add_qtc_executable
Change-Id: Icbeed128cc99b077aad925f278aaf9534d3f9fec Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Alessandro Portale
parent
8d767a3a21
commit
a5178afb61
@@ -6,85 +6,40 @@
|
||||
#
|
||||
# This way we are sure that all the binaries have been installed before.
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
|
||||
option(DEPLOY_QTC_DEPENDENCIES
|
||||
"Deployment of Qt, Clang, C++ Runtime libraries" ON)
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND DEPLOY_QTC_DEPENDENCIES)
|
||||
get_target_property(moc_binary Qt5::moc IMPORTED_LOCATION)
|
||||
get_filename_component(moc_dir "${moc_binary}" DIRECTORY)
|
||||
get_filename_component(qt5_base_dir "${moc_dir}/../" ABSOLUTE)
|
||||
get_filename_component(QT_BASE_DIR "${moc_dir}/../" ABSOLUTE)
|
||||
|
||||
if (MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(exclusion_mask PATTERN "*d.dll" EXCLUDE)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(qt5_plugin_dest_dir ${IDE_BIN_PATH}/plugins)
|
||||
set(qt5_qml_dest_dir ${IDE_BIN_PATH}/qml)
|
||||
elseif(APPLE)
|
||||
set(qt5_plugin_dest_dir ${IDE_PLUGIN_PATH})
|
||||
set(qt5_qml_dest_dir ${IDE_DATA_PATH}/../Imports/qtquick2)
|
||||
else()
|
||||
set(qt5_plugin_dest_dir ${IDE_LIBRARY_BASE_PATH}/Qt/plugins)
|
||||
set(qt5_qml_dest_dir ${IDE_LIBRARY_BASE_PATH}/Qt/qml)
|
||||
endif()
|
||||
|
||||
foreach(plugin
|
||||
designer iconengines imageformats platforms platformthemes
|
||||
printsupport qmltooling sqldrivers styles)
|
||||
if(NOT EXISTS "${qt5_base_dir}/plugins/${plugin}")
|
||||
assetimporters designer iconengines imageformats platforminputcontexts
|
||||
platforms platformthemes printsupport qmltooling sqldrivers styles
|
||||
xcbglintegrations)
|
||||
if(NOT EXISTS "${QT_BASE_DIR}/plugins/${plugin}")
|
||||
continue()
|
||||
endif()
|
||||
install(
|
||||
DIRECTORY "${qt5_base_dir}/plugins/${plugin}"
|
||||
DESTINATION ${qt5_plugin_dest_dir}
|
||||
DIRECTORY "${QT_BASE_DIR}/plugins/${plugin}"
|
||||
DESTINATION ${QT_DEST_PLUGIN_PATH}
|
||||
${exclusion_mask}
|
||||
)
|
||||
list(APPEND qt5_plugin_directories "${qt5_plugin_dest_dir}/${plugin}")
|
||||
list(APPEND QT_PLUGIN_DIRECTORIES "${QT_DEST_PLUGIN_PATH}/${plugin}")
|
||||
endforeach()
|
||||
|
||||
install(
|
||||
DIRECTORY "${qt5_base_dir}/qml/"
|
||||
DESTINATION ${qt5_qml_dest_dir}
|
||||
DIRECTORY "${QT_BASE_DIR}/qml/"
|
||||
DESTINATION ${QT_DEST_QML_PATH}
|
||||
PATTERN "qml/*"
|
||||
${exclusion_mask}
|
||||
)
|
||||
|
||||
install(CODE "
|
||||
function(create_qt_conf location base_dir)
|
||||
get_filename_component(install_prefix \"\${CMAKE_INSTALL_PREFIX}\" ABSOLUTE)
|
||||
file(RELATIVE_PATH qt_conf_binaries
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
\"\${install_prefix}/${IDE_BIN_PATH}\"
|
||||
)
|
||||
if (NOT qt_conf_binaries)
|
||||
set(qt_conf_binaries .)
|
||||
endif()
|
||||
file(RELATIVE_PATH qt_conf_plugins
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
\"\${install_prefix}/${qt5_plugin_dest_dir}\"
|
||||
)
|
||||
file(RELATIVE_PATH qt_conf_qml
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
\"\${install_prefix}/${qt5_qml_dest_dir}\"
|
||||
)
|
||||
|
||||
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/\${location}/qt.conf\"
|
||||
\"[Paths]\n\"
|
||||
\"Binaries=\${qt_conf_binaries}\n\"
|
||||
\"Plugins=\${qt_conf_plugins}\n\"
|
||||
\"Qml2Imports=\${qt_conf_qml}\n\"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
if(APPLE)
|
||||
create_qt_conf(\"${IDE_DATA_PATH}\" \"${IDE_DATA_PATH}/..\")
|
||||
create_qt_conf(\"${IDE_LIBEXEC_PATH}\" \"${IDE_DATA_PATH}/..\")
|
||||
else()
|
||||
create_qt_conf(\"${IDE_APP_PATH}\" \"${IDE_APP_PATH}\")
|
||||
create_qt_conf(\"${IDE_LIBEXEC_PATH}\" \"${IDE_LIBEXEC_PATH}\")
|
||||
endif()
|
||||
|
||||
"
|
||||
)
|
||||
|
||||
# Analyze the binaries and install missing dependencies if they are
|
||||
# found the CMAKE_PREFIX_PATH e.g. Qt, Clang
|
||||
configure_file(InstallDependentSharedObjects.cmake.in InstallDependentSharedObjects.cmake @ONLY)
|
||||
|
@@ -10,14 +10,15 @@ endif()
|
||||
get_filename_component(install_prefix "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
|
||||
|
||||
# Get the dependencies of Qt's plugins
|
||||
foreach(plugin @qt5_plugin_directories@)
|
||||
set(qt_plugin_directories "@QT_PLUGIN_DIRECTORIES@")
|
||||
foreach(plugin IN LISTS qt_plugin_directories)
|
||||
file(GLOB plugin_files "${install_prefix}/${plugin}/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
list(APPEND qt5_plugin_files "${plugin_files}")
|
||||
list(APPEND qt_plugin_files "${plugin_files}")
|
||||
endforeach()
|
||||
|
||||
# Get the qml module dependencies
|
||||
file(GLOB_RECURSE qml_plugin_files "${install_prefix}/@qt5_qml_dest_dir@/*/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
list(APPEND qt5_plugin_files "${qml_plugin_files}")
|
||||
file(GLOB_RECURSE qml_plugin_files "${install_prefix}/@QT_DEST_QML_PATH@/*/*@CMAKE_SHARED_LIBRARY_SUFFIX@")
|
||||
list(APPEND qt_plugin_files "${qml_plugin_files}")
|
||||
|
||||
set(installed_EXECUTABLES_NOT_PREFIXED "@__QTC_INSTALLED_EXECUTABLES@")
|
||||
set(installed_LIBRARIES_NOT_PREFIXED "@__QTC_INSTALLED_LIBRARIES@")
|
||||
@@ -74,7 +75,7 @@ while(installed_libraries_size GREATER 0)
|
||||
endif()
|
||||
|
||||
set(qt_plugins_installed TRUE)
|
||||
set(installed_MODULES "${qt5_plugin_files}")
|
||||
set(installed_MODULES "${qt_plugin_files}")
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES unresolved_deps)
|
||||
@@ -125,7 +126,7 @@ while(installed_libraries_size GREATER 0)
|
||||
set(so_dest "${install_prefix}/@IDE_LIBRARY_PATH@/${so_dir}")
|
||||
else()
|
||||
set(so_src "${p}/lib/${so}")
|
||||
if (p STREQUAL "@qt5_base_dir@")
|
||||
if (p STREQUAL "@QT_BASE_DIR@")
|
||||
set(so_dest "${install_prefix}/@IDE_LIBRARY_BASE_PATH@/Qt/lib")
|
||||
else()
|
||||
set(so_dest "${install_prefix}/@IDE_LIBRARY_PATH@")
|
||||
|
@@ -46,6 +46,9 @@ if (APPLE)
|
||||
set(_IDE_DATA_PATH "${_IDE_OUTPUT_PATH}/Resources")
|
||||
set(_IDE_DOC_PATH "${_IDE_OUTPUT_PATH}/Resources/doc")
|
||||
set(_IDE_BIN_PATH "${_IDE_OUTPUT_PATH}/MacOS")
|
||||
|
||||
set(QT_DEST_PLUGIN_PATH "${_IDE_PLUGIN_PATH}")
|
||||
set(QT_DEST_QML_PATH "${_IDE_DATA_PATH}/../Imports/qtquick2")
|
||||
else ()
|
||||
set(_IDE_APP_PATH "bin")
|
||||
set(_IDE_APP_TARGET "${IDE_ID}")
|
||||
@@ -55,8 +58,12 @@ else ()
|
||||
set(_IDE_PLUGIN_PATH "lib/${IDE_ID}/plugins")
|
||||
if (WIN32)
|
||||
set(_IDE_LIBEXEC_PATH "bin")
|
||||
set(QT_DEST_PLUGIN_PATH "bin/plugins")
|
||||
set(QT_DEST_QML_PATH "bin/qml")
|
||||
else ()
|
||||
set(_IDE_LIBEXEC_PATH "libexec/${IDE_ID}/bin")
|
||||
set(QT_DEST_PLUGIN_PATH "lib/Qt/plugins")
|
||||
set(QT_DEST_QML_PATH "lib/Qt/qml")
|
||||
endif ()
|
||||
set(_IDE_DATA_PATH "share/${IDE_ID}")
|
||||
set(_IDE_DOC_PATH "share/doc/${IDE_ID}")
|
||||
@@ -946,6 +953,48 @@ function(add_qtc_executable name)
|
||||
install(TARGETS ${name} DESTINATION "${_DESTINATION}" OPTIONAL)
|
||||
update_cached_list(__QTC_INSTALLED_EXECUTABLES
|
||||
"${_DESTINATION}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
|
||||
install(CODE "
|
||||
function(create_qt_conf location base_dir)
|
||||
get_filename_component(install_prefix \"\${CMAKE_INSTALL_PREFIX}\" ABSOLUTE)
|
||||
file(RELATIVE_PATH qt_conf_binaries
|
||||
\"\${install_prefix}/\${location}\"
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
)
|
||||
if (NOT qt_conf_binaries)
|
||||
set(qt_conf_binaries .)
|
||||
endif()
|
||||
file(RELATIVE_PATH qt_conf_plugins
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
\"\${install_prefix}/${QT_DEST_PLUGIN_PATH}\"
|
||||
)
|
||||
file(RELATIVE_PATH qt_conf_qml
|
||||
\"\${install_prefix}/\${base_dir}\"
|
||||
\"\${install_prefix}/${QT_DEST_QML_PATH}\"
|
||||
)
|
||||
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/\${location}/qt.conf\"
|
||||
\"[Paths]\n\"
|
||||
\"Plugins=\${qt_conf_plugins}\n\"
|
||||
\"Qml2Imports=\${qt_conf_qml}\n\"
|
||||
)
|
||||
# For Apple for Qt Creator do not add a Prefix
|
||||
if (NOT APPLE OR NOT qt_conf_binaries STREQUAL \"../\")
|
||||
file(APPEND \"\${CMAKE_INSTALL_PREFIX}/\${location}/qt.conf\"
|
||||
\"Prefix=\${qt_conf_binaries}\n\"
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
if(APPLE)
|
||||
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_DATA_PATH}/..\")
|
||||
elseif (WIN32)
|
||||
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_APP_PATH}\")
|
||||
else()
|
||||
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_LIBRARY_BASE_PATH}/Qt\")
|
||||
endif()
|
||||
"
|
||||
)
|
||||
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
Reference in New Issue
Block a user