DeployQt4: Do not include BundleUtilities at configure time

Due to CMP0080, BundleUtilities can no longer be included at
configure-time. However, DeployQt4 contains some functions which
are meant to be used at configure-time, and some which are meant
to be used at install-time and use BundleUtilities. This change
breaks the file into two sections: common functions and install-time
functions. BundleUtilities is now only included at install-time,
thus fixing the policy warning.

Fixes: #18466
This commit is contained in:
Kyle Edwards
2018-10-17 10:25:23 -04:00
parent 65bea5b90b
commit 15bbff0581
2 changed files with 89 additions and 74 deletions

View File

@@ -224,17 +224,21 @@ that are already also in the bundle... Anything that points to an
external file causes this function to fail the verification.
#]=======================================================================]
function(_warn_cmp0080)
message(AUTHOR_WARNING
"Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. "
"Run \"cmake --help-policy CMP0080\" for policy details. "
"Use the cmake_policy command to set the policy and suppress this warning."
)
endfunction()
# Do not include this module at configure time!
if(DEFINED CMAKE_GENERATOR)
cmake_policy(GET CMP0080 _BundleUtilities_CMP0080)
if(_BundleUtilities_CMP0080 STREQUAL "NEW")
message(FATAL_ERROR "BundleUtilities cannot be included at configure time!")
elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD")
message(AUTHOR_WARNING
"Policy CMP0080 is not set: BundleUtilities prefers not to be included at configure time. "
"Run \"cmake --help-policy CMP0080\" for policy details. "
"Use the cmake_policy command to set the policy and suppress this warning."
)
elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD" AND NOT _CMP0080_SUPPRESS_WARNING)
_warn_cmp0080()
endif()
endif()

View File

@@ -106,7 +106,6 @@ and plugin installation. See documentation of FIXUP_QT4_BUNDLE.
# The functions defined in this file depend on the fixup_bundle function
# (and others) found in BundleUtilities.cmake
include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
set(DeployQt4_apple_plugins_dir "PlugIns")
@@ -137,80 +136,92 @@ function(resolve_qt4_paths paths_var)
set(${paths_var} ${paths_resolved} PARENT_SCOPE)
endfunction()
function(fixup_qt4_executable executable)
unset(qtplugins)
if(ARGC GREATER 1)
set(qtplugins ${ARGV1})
endif()
unset(libs)
if(ARGC GREATER 2)
set(libs ${ARGV2})
endif()
unset(dirs)
if(ARGC GREATER 3)
set(dirs ${ARGV3})
endif()
unset(plugins_dir)
if(ARGC GREATER 4)
set(plugins_dir ${ARGV4})
endif()
unset(request_qt_conf)
if(ARGC GREATER 5)
set(request_qt_conf ${ARGV5})
endif()
cmake_policy(GET CMP0080 _cmp0080_value)
if(NOT DEFINED CMAKE_GENERATOR OR NOT _cmp0080_value STREQUAL "NEW")
set(_CMP0080_SUPPRESS_WARNING TRUE)
include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
unset(_CMP0080_SUPPRESS_WARNING)
message(STATUS "fixup_qt4_executable")
message(STATUS " executable='${executable}'")
message(STATUS " qtplugins='${qtplugins}'")
message(STATUS " libs='${libs}'")
message(STATUS " dirs='${dirs}'")
message(STATUS " plugins_dir='${plugins_dir}'")
message(STATUS " request_qt_conf='${request_qt_conf}'")
if(QT_LIBRARY_DIR)
list(APPEND dirs "${QT_LIBRARY_DIR}")
endif()
if(QT_BINARY_DIR)
list(APPEND dirs "${QT_BINARY_DIR}")
endif()
if(APPLE)
set(qt_conf_dir "${executable}/Contents/Resources")
set(executable_path "${executable}")
set(write_qt_conf TRUE)
if(NOT DEFINED plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
function(fixup_qt4_executable executable)
cmake_policy(GET CMP0080 _cmp0080_value)
if(_cmp0080_value STREQUAL "" AND DEFINED CMAKE_GENERATOR)
_warn_cmp0080()
endif()
else()
get_filename_component(executable_path "${executable}" PATH)
if(NOT executable_path)
set(executable_path ".")
unset(qtplugins)
if(ARGC GREATER 1)
set(qtplugins ${ARGV1})
endif()
set(qt_conf_dir "${executable_path}")
set(write_qt_conf ${request_qt_conf})
endif()
foreach(plugin ${qtplugins})
set(installed_plugin_path "")
install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
list(APPEND libs ${installed_plugin_path})
endforeach()
foreach(lib ${libs})
if(NOT EXISTS "${lib}")
message(FATAL_ERROR "Library does not exist: ${lib}")
unset(libs)
if(ARGC GREATER 2)
set(libs ${ARGV2})
endif()
unset(dirs)
if(ARGC GREATER 3)
set(dirs ${ARGV3})
endif()
unset(plugins_dir)
if(ARGC GREATER 4)
set(plugins_dir ${ARGV4})
endif()
unset(request_qt_conf)
if(ARGC GREATER 5)
set(request_qt_conf ${ARGV5})
endif()
endforeach()
resolve_qt4_paths(libs "${executable_path}")
message(STATUS "fixup_qt4_executable")
message(STATUS " executable='${executable}'")
message(STATUS " qtplugins='${qtplugins}'")
message(STATUS " libs='${libs}'")
message(STATUS " dirs='${dirs}'")
message(STATUS " plugins_dir='${plugins_dir}'")
message(STATUS " request_qt_conf='${request_qt_conf}'")
if(write_qt_conf)
set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
endif()
if(QT_LIBRARY_DIR)
list(APPEND dirs "${QT_LIBRARY_DIR}")
endif()
if(QT_BINARY_DIR)
list(APPEND dirs "${QT_BINARY_DIR}")
endif()
fixup_bundle("${executable}" "${libs}" "${dirs}")
endfunction()
if(APPLE)
set(qt_conf_dir "${executable}/Contents/Resources")
set(executable_path "${executable}")
set(write_qt_conf TRUE)
if(NOT DEFINED plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif()
else()
get_filename_component(executable_path "${executable}" PATH)
if(NOT executable_path)
set(executable_path ".")
endif()
set(qt_conf_dir "${executable_path}")
set(write_qt_conf ${request_qt_conf})
endif()
foreach(plugin ${qtplugins})
set(installed_plugin_path "")
install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
list(APPEND libs ${installed_plugin_path})
endforeach()
foreach(lib ${libs})
if(NOT EXISTS "${lib}")
message(FATAL_ERROR "Library does not exist: ${lib}")
endif()
endforeach()
resolve_qt4_paths(libs "${executable_path}")
if(write_qt_conf)
set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
endif()
fixup_bundle("${executable}" "${libs}" "${dirs}")
endfunction()
endif()
function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var)
unset(plugins_dir)