DeployQt4: Convert to 2-space indentation

This commit is contained in:
Kyle Edwards
2018-10-17 10:23:10 -04:00
parent 9bfb63bd42
commit 65bea5b90b
+242 -242
View File
@@ -111,279 +111,279 @@ set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
set(DeployQt4_apple_plugins_dir "PlugIns") set(DeployQt4_apple_plugins_dir "PlugIns")
function(write_qt4_conf qt_conf_dir qt_conf_contents) function(write_qt4_conf qt_conf_dir qt_conf_contents)
set(qt_conf_path "${qt_conf_dir}/qt.conf") set(qt_conf_path "${qt_conf_dir}/qt.conf")
message(STATUS "Writing ${qt_conf_path}") message(STATUS "Writing ${qt_conf_path}")
file(WRITE "${qt_conf_path}" "${qt_conf_contents}") file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
endfunction() endfunction()
function(resolve_qt4_paths paths_var) function(resolve_qt4_paths paths_var)
unset(executable_path) unset(executable_path)
if(ARGC GREATER 1) if(ARGC GREATER 1)
set(executable_path ${ARGV1}) set(executable_path ${ARGV1})
endif() endif()
set(paths_resolved) set(paths_resolved)
foreach(path ${${paths_var}}) foreach(path ${${paths_var}})
if(EXISTS "${path}") if(EXISTS "${path}")
list(APPEND paths_resolved "${path}") list(APPEND paths_resolved "${path}")
else() else()
if(${executable_path}) if(${executable_path})
list(APPEND paths_resolved "${executable_path}/${path}") list(APPEND paths_resolved "${executable_path}/${path}")
else() else()
list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}") list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
endif() endif()
endif() endif()
endforeach() endforeach()
set(${paths_var} ${paths_resolved} PARENT_SCOPE) set(${paths_var} ${paths_resolved} PARENT_SCOPE)
endfunction() endfunction()
function(fixup_qt4_executable executable) function(fixup_qt4_executable executable)
unset(qtplugins) unset(qtplugins)
if(ARGC GREATER 1) if(ARGC GREATER 1)
set(qtplugins ${ARGV1}) set(qtplugins ${ARGV1})
endif() endif()
unset(libs) unset(libs)
if(ARGC GREATER 2) if(ARGC GREATER 2)
set(libs ${ARGV2}) set(libs ${ARGV2})
endif() endif()
unset(dirs) unset(dirs)
if(ARGC GREATER 3) if(ARGC GREATER 3)
set(dirs ${ARGV3}) set(dirs ${ARGV3})
endif() endif()
unset(plugins_dir) unset(plugins_dir)
if(ARGC GREATER 4) if(ARGC GREATER 4)
set(plugins_dir ${ARGV4}) set(plugins_dir ${ARGV4})
endif() endif()
unset(request_qt_conf) unset(request_qt_conf)
if(ARGC GREATER 5) if(ARGC GREATER 5)
set(request_qt_conf ${ARGV5}) set(request_qt_conf ${ARGV5})
endif() endif()
message(STATUS "fixup_qt4_executable") message(STATUS "fixup_qt4_executable")
message(STATUS " executable='${executable}'") message(STATUS " executable='${executable}'")
message(STATUS " qtplugins='${qtplugins}'") message(STATUS " qtplugins='${qtplugins}'")
message(STATUS " libs='${libs}'") message(STATUS " libs='${libs}'")
message(STATUS " dirs='${dirs}'") message(STATUS " dirs='${dirs}'")
message(STATUS " plugins_dir='${plugins_dir}'") message(STATUS " plugins_dir='${plugins_dir}'")
message(STATUS " request_qt_conf='${request_qt_conf}'") message(STATUS " request_qt_conf='${request_qt_conf}'")
if(QT_LIBRARY_DIR) if(QT_LIBRARY_DIR)
list(APPEND dirs "${QT_LIBRARY_DIR}") list(APPEND dirs "${QT_LIBRARY_DIR}")
endif() endif()
if(QT_BINARY_DIR) if(QT_BINARY_DIR)
list(APPEND dirs "${QT_BINARY_DIR}") list(APPEND dirs "${QT_BINARY_DIR}")
endif() endif()
if(APPLE) if(APPLE)
set(qt_conf_dir "${executable}/Contents/Resources") set(qt_conf_dir "${executable}/Contents/Resources")
set(executable_path "${executable}") set(executable_path "${executable}")
set(write_qt_conf TRUE) set(write_qt_conf TRUE)
if(NOT DEFINED plugins_dir) if(NOT DEFINED plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}") set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif() endif()
else() else()
get_filename_component(executable_path "${executable}" PATH) get_filename_component(executable_path "${executable}" PATH)
if(NOT executable_path) if(NOT executable_path)
set(executable_path ".") set(executable_path ".")
endif() endif()
set(qt_conf_dir "${executable_path}") set(qt_conf_dir "${executable_path}")
set(write_qt_conf ${request_qt_conf}) set(write_qt_conf ${request_qt_conf})
endif() endif()
foreach(plugin ${qtplugins}) foreach(plugin ${qtplugins})
set(installed_plugin_path "") set(installed_plugin_path "")
install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path) install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
list(APPEND libs ${installed_plugin_path}) list(APPEND libs ${installed_plugin_path})
endforeach() endforeach()
foreach(lib ${libs}) foreach(lib ${libs})
if(NOT EXISTS "${lib}") if(NOT EXISTS "${lib}")
message(FATAL_ERROR "Library does not exist: ${lib}") message(FATAL_ERROR "Library does not exist: ${lib}")
endif() endif()
endforeach() endforeach()
resolve_qt4_paths(libs "${executable_path}") resolve_qt4_paths(libs "${executable_path}")
if(write_qt_conf) if(write_qt_conf)
set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
endif() endif()
fixup_bundle("${executable}" "${libs}" "${dirs}") fixup_bundle("${executable}" "${libs}" "${dirs}")
endfunction() endfunction()
function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var) function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var)
unset(plugins_dir) unset(plugins_dir)
if(ARGC GREATER 4) if(ARGC GREATER 4)
set(plugins_dir ${ARGV4}) set(plugins_dir ${ARGV4})
endif() endif()
unset(component) unset(component)
if(ARGC GREATER 5) if(ARGC GREATER 5)
set(component ${ARGV5}) set(component ${ARGV5})
endif() endif()
unset(configurations)
if(ARGC GREATER 6)
set(configurations ${ARGV6})
endif()
if(EXISTS "${plugin}")
if(APPLE)
if(NOT plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif()
set(plugins_path "${executable}/Contents/${plugins_dir}")
else()
get_filename_component(plugins_path "${executable}" PATH)
if(NOT plugins_path)
set(plugins_path ".")
endif()
if(plugins_dir)
string(APPEND plugins_path "/${plugins_dir}")
endif()
endif()
set(plugin_group "")
get_filename_component(plugin_path "${plugin}" PATH)
get_filename_component(plugin_parent_path "${plugin_path}" PATH)
get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
get_filename_component(plugin_name "${plugin}" NAME)
string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
if("${plugin_parent_dir_name}" STREQUAL "plugins")
get_filename_component(plugin_group "${plugin_path}" NAME)
set(${plugin_group_var} "${plugin_group}")
endif()
string(APPEND plugins_path "/${plugin_group}")
if(${copy})
file(MAKE_DIRECTORY "${plugins_path}")
file(COPY "${plugin}" DESTINATION "${plugins_path}")
else()
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
set(configurations CONFIGURATIONS ${configurations})
else()
unset(configurations) unset(configurations)
if(ARGC GREATER 6) endif()
set(configurations ${ARGV6}) install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
endif() endif()
set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
if(EXISTS "${plugin}") endif()
if(APPLE)
if(NOT plugins_dir)
set(plugins_dir "${DeployQt4_apple_plugins_dir}")
endif()
set(plugins_path "${executable}/Contents/${plugins_dir}")
else()
get_filename_component(plugins_path "${executable}" PATH)
if(NOT plugins_path)
set(plugins_path ".")
endif()
if(plugins_dir)
string(APPEND plugins_path "/${plugins_dir}")
endif()
endif()
set(plugin_group "")
get_filename_component(plugin_path "${plugin}" PATH)
get_filename_component(plugin_parent_path "${plugin_path}" PATH)
get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
get_filename_component(plugin_name "${plugin}" NAME)
string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
if("${plugin_parent_dir_name}" STREQUAL "plugins")
get_filename_component(plugin_group "${plugin_path}" NAME)
set(${plugin_group_var} "${plugin_group}")
endif()
string(APPEND plugins_path "/${plugin_group}")
if(${copy})
file(MAKE_DIRECTORY "${plugins_path}")
file(COPY "${plugin}" DESTINATION "${plugins_path}")
else()
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
set(configurations CONFIGURATIONS ${configurations})
else()
unset(configurations)
endif()
install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
endif()
set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
endif()
endfunction() endfunction()
function(install_qt4_plugin plugin executable copy installed_plugin_path_var) function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
unset(plugins_dir) unset(plugins_dir)
if(ARGC GREATER 4) if(ARGC GREATER 4)
set(plugins_dir ${ARGV4}) set(plugins_dir ${ARGV4})
endif() endif()
unset(component) unset(component)
if(ARGC GREATER 5) if(ARGC GREATER 5)
set(component ${ARGV5}) set(component ${ARGV5})
endif() endif()
if(EXISTS "${plugin}") if(EXISTS "${plugin}")
install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
else() else()
string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
set(plugin_release_var "${plugin_var}_RELEASE") set(plugin_release_var "${plugin_var}_RELEASE")
set(plugin_debug_var "${plugin_var}_DEBUG") set(plugin_debug_var "${plugin_var}_DEBUG")
set(plugin_release "${${plugin_release_var}}") set(plugin_release "${${plugin_release_var}}")
set(plugin_debug "${${plugin_debug_var}}") set(plugin_debug "${${plugin_debug_var}}")
if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
endif() endif()
if(NOT EXISTS "${${plugin_debug_var}}") if(NOT EXISTS "${${plugin_debug_var}}")
set(plugin_debug "${plugin_release}") set(plugin_debug "${plugin_release}")
endif() endif()
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig OR CMAKE_BUILD_TYPE) if(_isMultiConfig OR CMAKE_BUILD_TYPE)
set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}") set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}")
if (_RELEASE_CONFIGS) if (_RELEASE_CONFIGS)
list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]") list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]")
endif() endif()
string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}") string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}")
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}") install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}")
install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug") install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
unset(_RELEASE_CONFIGS) unset(_RELEASE_CONFIGS)
if(CMAKE_BUILD_TYPE MATCHES "^Debug$") if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug}) set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
else() else()
set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release}) set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
endif() endif()
else() else()
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
endif() endif()
endif() endif()
set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE) set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
endfunction() endfunction()
function(install_qt4_executable executable) function(install_qt4_executable executable)
unset(qtplugins) unset(qtplugins)
if(ARGC GREATER 1) if(ARGC GREATER 1)
set(qtplugins ${ARGV1}) set(qtplugins ${ARGV1})
endif() endif()
unset(libs) unset(libs)
if(ARGC GREATER 2) if(ARGC GREATER 2)
set(libs ${ARGV2}) set(libs ${ARGV2})
endif() endif()
unset(dirs) unset(dirs)
if(ARGC GREATER 3) if(ARGC GREATER 3)
set(dirs ${ARGV3}) set(dirs ${ARGV3})
endif() endif()
unset(plugins_dir) unset(plugins_dir)
if(ARGC GREATER 4) if(ARGC GREATER 4)
set(plugins_dir ${ARGV4}) set(plugins_dir ${ARGV4})
endif() endif()
unset(request_qt_conf) unset(request_qt_conf)
if(ARGC GREATER 5) if(ARGC GREATER 5)
set(request_qt_conf ${ARGV5}) set(request_qt_conf ${ARGV5})
endif() endif()
unset(component) unset(component)
if(ARGC GREATER 6) if(ARGC GREATER 6)
set(component ${ARGV6}) set(component ${ARGV6})
endif() endif()
if(QT_LIBRARY_DIR) if(QT_LIBRARY_DIR)
list(APPEND dirs "${QT_LIBRARY_DIR}") list(APPEND dirs "${QT_LIBRARY_DIR}")
endif() endif()
if(QT_BINARY_DIR) if(QT_BINARY_DIR)
list(APPEND dirs "${QT_BINARY_DIR}") list(APPEND dirs "${QT_BINARY_DIR}")
endif() endif()
if(component) if(component)
set(component COMPONENT ${component}) set(component COMPONENT ${component})
else() else()
unset(component) unset(component)
endif() endif()
get_filename_component(executable_absolute "${executable}" ABSOLUTE) get_filename_component(executable_absolute "${executable}" ABSOLUTE)
if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}") if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type) gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}") elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type) gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
endif() endif()
if(qtcore_type STREQUAL "system") if(qtcore_type STREQUAL "system")
set(qt_plugins_dir "") set(qt_plugins_dir "")
endif() endif()
if(QT_IS_STATIC) if(QT_IS_STATIC)
message(WARNING "Qt built statically: not installing plugins.") message(WARNING "Qt built statically: not installing plugins.")
else() else()
foreach(plugin ${qtplugins}) foreach(plugin ${qtplugins})
set(installed_plugin_paths "") set(installed_plugin_paths "")
install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
list(APPEND libs ${installed_plugin_paths}) list(APPEND libs ${installed_plugin_paths})
endforeach() endforeach()
endif() endif()
resolve_qt4_paths(libs "") resolve_qt4_paths(libs "")
install(CODE install(CODE
"include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\") "include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\")
set(BU_CHMOD_BUNDLE_ITEMS TRUE) set(BU_CHMOD_BUNDLE_ITEMS TRUE)
FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")" FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
${component} ${component}
) )
endfunction() endfunction()