Remove perl related functionality from CMake files

Avoid using perl in CMake scripts. Remove the syncqt.pl specific
code.

Task-number: QTBUG-87480
Change-Id: I7fcd5cc83d173ec463c275b5b50b84f25044a118
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2022-10-05 16:32:31 +02:00
parent 5a72b327fd
commit 7f4aa1a3fa
11 changed files with 43 additions and 381 deletions

View File

@ -233,10 +233,6 @@ if(CMAKE_HOST_APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS "19.0.0")
message(FATAL_ERROR "macOS versions less than 10.15 are not supported for building Qt.")
endif()
if(NOT DEFINED QT_USE_SYNCQT_CPP)
set(QT_USE_SYNCQT_CPP FALSE)
endif()
# the default RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")

View File

@ -198,19 +198,6 @@ function(qt_internal_warn_about_buggy_cmake_versions)
# Fixed in 3.21.2.
list(APPEND unsuitable_versions "3.21.1")
# qt_ensure_perl fails to find perl in host PATH via find_program
# due to Android Platform module setting CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH to OFF
# Fixed in 3.20.6, 3.21.3. not a problem in CMake versions earlier than 3.20.0
# https://gitlab.kitware.com/cmake/cmake/-/issues/22634
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5357
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6528
if(ANDROID AND CMAKE_HOST_WIN32)
list(APPEND unsuitable_versions
"3.20.0" "3.20.1" "3.20.2" "3.20.3" "3.20.4" "3.20.5"
"3.21.0" "3.21.1" "3.21.2"
)
endif()
foreach(unsuitable_version ${unsuitable_versions})
if(CMAKE_VERSION VERSION_EQUAL unsuitable_version)
message(WARNING

View File

@ -140,12 +140,10 @@ function(qt_internal_add_docs)
)
add_dependencies(prepare_docs_${target} qattributionsscanner_${target})
if(QT_USE_SYNCQT_CPP)
if(NOT TARGET sync_all_public_headers)
add_custom_target(sync_all_public_headers)
endif()
add_dependencies(prepare_docs_${target} sync_all_public_headers)
endif()
# generate docs target
set(generate_qdoc_args

View File

@ -662,22 +662,6 @@ function(qt_feature_module_end)
)
endif()
# Extra header injections which have to have forwarding headers created by
# qt_install_injections.
# Skip creating forwarding headers if qt_feature_module_begin was called with NO_MODULE, aka
# there is no include/<module_name> so there's no place to put the forwarding headers.
if(__QtFeature_library)
set(injections "")
qt_compute_injection_forwarding_header("${__QtFeature_library}"
SOURCE "${__QtFeature_public_file}"
OUT_VAR injections)
qt_compute_injection_forwarding_header("${__QtFeature_library}"
SOURCE "${__QtFeature_private_file}" PRIVATE
OUT_VAR injections)
set(${arg_OUT_VAR_PREFIX}extra_library_injections ${injections} PARENT_SCOPE)
endif()
if (NOT ("${target}" STREQUAL "NO_MODULE") AND NOT arg_ONLY_EVALUATE_FEATURES)
get_target_property(targetType "${target}" TYPE)
if("${targetType}" STREQUAL "INTERFACE_LIBRARY")

View File

@ -4,8 +4,6 @@
# This function generates LD version script for the target and uses it in the target linker line.
# Function has two modes dependending on the specified arguments.
# Arguments:
# PRIVATE_HEADERS specifies the list of header files that are used to generate
# Qt_<version>_PRIVATE_API section. Requires perl.
# PRIVATE_CONTENT_FILE specifies the pre-cooked content of Qt_<version>_PRIVATE_API section.
# Requires the content file available at build time.
function(qt_internal_add_linker_version_script target)
@ -57,17 +55,6 @@ function(qt_internal_add_linker_version_script target)
file(GENERATE OUTPUT "${infile}" CONTENT "${contents}")
if(arg_PRIVATE_HEADERS)
qt_ensure_perl()
set(generator_command "${HOST_PERL}"
"${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl"
"<" "${infile}" ">" "${outfile}"
)
set(generator_dependencies
"${infile}"
"${QT_MKSPECS_DIR}/features/data/unix/findclasslist.pl"
)
else()
if(NOT arg_PRIVATE_CONTENT_FILE)
set(arg_PRIVATE_CONTENT_FILE "")
endif()
@ -81,7 +68,6 @@ function(qt_internal_add_linker_version_script target)
"${arg_PRIVATE_CONTENT_FILE}"
"${QT_CMAKE_DIR}/QtGenerateVersionScript.cmake"
)
endif()
add_custom_command(
OUTPUT "${outfile}"

View File

@ -212,10 +212,8 @@ function(qt_internal_add_headersclean_target module_target module_headers)
qt_internal_module_info(module ${module_target})
unset(header_check_exceptions)
if(QT_USE_SYNCQT_CPP)
set(header_check_exceptions
"${CMAKE_CURRENT_BINARY_DIR}/${module}_header_check_exceptions")
endif()
set(headers_check_parameters
"${CMAKE_CURRENT_BINARY_DIR}/${module_target}HeadersCheckParameters${config_suffix}.cmake")
string(JOIN "\n" headers_check_parameters_content
@ -229,10 +227,7 @@ function(qt_internal_add_headersclean_target module_target module_headers)
file(GENERATE OUTPUT "${headers_check_parameters}"
CONTENT "${headers_check_parameters_content}")
set(sync_headers_dep "")
if(QT_USE_SYNCQT_CPP)
set(sync_headers_dep "sync_headers")
endif()
foreach(header ${hclean_headers})
# We need realpath here to make sure path starts with drive letter

View File

@ -394,39 +394,12 @@ function(qt_internal_add_module target)
_qt_module_has_headers ON
)
# Need to call qt_ensure_sync_qt to install syncqt.pl script.
qt_ensure_sync_qt()
# Repo uses old perl script to sync files.
if(NOT QT_USE_SYNCQT_CPP)
# Use QT_BUILD_DIR for the syncqt call.
# So we either write the generated files into the qtbase non-prefix build root, or the
# module specific build root.
set(syncqt_full_command "${HOST_PERL}" -w "${QT_SYNCQT}"
-quiet
-check-includes
-module "${module_include_name}"
-version "${PROJECT_VERSION}"
-outdir "${QT_BUILD_DIR}"
-builddir "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}")
message(STATUS "Running syncqt for module: '${module_include_name}' ")
execute_process(COMMAND ${syncqt_full_command} RESULT_VARIABLE syncqt_ret)
if(NOT syncqt_ret EQUAL 0)
message(FATAL_ERROR "Failed to run syncqt, return code: ${syncqt_ret}")
endif()
### FIXME: Can we replace headers.pri?
qt_read_headers_pri("${module_build_interface_include_dir}" "module_headers")
set_property(TARGET ${target} APPEND PROPERTY
_qt_module_timestamp_dependencies "${module_headers_generated}")
else()
set(sync_source_directory "${CMAKE_CURRENT_SOURCE_DIR}")
if(arg_HEADER_SYNC_SOURCE_DIRECTORY)
set(sync_source_directory "${arg_HEADER_SYNC_SOURCE_DIRECTORY}")
endif()
set_target_properties(${target} PROPERTIES
_qt_sync_source_directory "${sync_source_directory}")
endif()
# We should not generate export headers if module is defined as pure STATIC.
# Static libraries don't need to export their symbols, and corner cases when sources are
# also used in shared libraries, should be handled manually.
@ -476,18 +449,6 @@ function(qt_internal_add_module target)
qt_install(DIRECTORY "${arg_EXTERNAL_HEADERS_DIR}/"
DESTINATION "${module_install_interface_include_dir}"
)
else()
if(NOT QT_USE_SYNCQT_CPP)
if(arg_EXTERNAL_HEADERS)
set(module_headers_public "${arg_EXTERNAL_HEADERS}")
endif()
qt_internal_install_module_headers(${target}
PUBLIC
${module_headers_public}
"${module_depends_header}"
"${module_header}"
)
endif()
endif()
endif()
@ -681,31 +642,6 @@ function(qt_internal_add_module target)
)
endif()
if(NOT arg_HEADER_MODULE AND NOT QT_USE_SYNCQT_CPP)
if(DEFINED module_headers_private)
qt_internal_add_linker_version_script("${target}" PRIVATE_HEADERS ${module_headers_private} ${module_headers_qpa})
else()
qt_internal_add_linker_version_script("${target}")
endif()
endif()
# Handle injections. Aka create forwarding headers for certain headers that have been
# automatically generated in the build dir (for example qconfig.h, qtcore-config.h,
# qvulkanfunctions.h, etc)
# module_headers_injections come from the qt_read_headers_pri() call.
# extra_library_injections come from the qt_feature_module_end() call.
set(final_injections "")
if(module_headers_injections)
string(APPEND final_injections "${module_headers_injections} ")
endif()
if(extra_library_injections)
string(APPEND final_injections "${extra_library_injections} ")
endif()
if(final_injections AND NOT QT_USE_SYNCQT_CPP)
qt_install_injections(${target} "${QT_BUILD_DIR}" "${QT_INSTALL_DIR}" ${final_injections})
endif()
# Handle creation of cmake files for consumers of find_package().
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
@ -884,12 +820,6 @@ set(QT_LIBINFIX \"${QT_LIBINFIX}\")")
endif()
endif()
if(NOT QT_USE_SYNCQT_CPP)
qt_internal_add_headersclean_target(
${target}
"${module_headers_clean}")
endif()
if(arg_INTERNAL_MODULE)
target_include_directories("${target}" INTERFACE ${interface_includes})
elseif(NOT ${arg_NO_PRIVATE_MODULE})
@ -925,7 +855,6 @@ function(qt_finalize_module target)
# qt_finalize_framework_headers_copy, because the last uses the QT_COPIED_FRAMEWORK_HEADERS
# property which supposed to be updated inside every qt_internal_install_module_headers
# call.
if(QT_USE_SYNCQT_CPP)
qt_internal_add_headersclean_target(${target} "${module_headers_public}")
qt_internal_target_sync_headers(${target} "${module_headers_all}"
"${module_headers_generated}")
@ -935,12 +864,6 @@ function(qt_finalize_module target)
PRIVATE ${module_headers_private}
QPA ${module_headers_qpa}
)
else()
qt_internal_install_module_headers(${target}
PRIVATE ${module_headers_private}
QPA ${module_headers_qpa}
)
endif()
qt_finalize_framework_headers_copy(${target})
qt_generate_prl_file(${target} "${INSTALL_LIBDIR}")
@ -1140,12 +1063,6 @@ function(qt_internal_generate_cpp_global_exports target module_define_infix)
set(${out_public_header} "${generated_header_path}" PARENT_SCOPE)
target_sources(${target} PRIVATE "${generated_header_path}")
set_source_files_properties("${generated_header_path}" PROPERTIES GENERATED TRUE)
if(NOT QT_USE_SYNCQT_CPP)
qt_internal_install_module_headers(${target}
PUBLIC
"${generated_header_path}"
)
endif()
if(arg_GENERATE_PRIVATE_CPP_EXPORTS)
set(generated_private_header_path

View File

@ -1,212 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
function(qt_ensure_perl)
find_program(HOST_PERL "perl" DOC "Perl binary")
if (NOT HOST_PERL)
message(FATAL_ERROR "Perl needs to be available to build Qt.")
endif()
endfunction()
function(qt_ensure_sync_qt)
qt_ensure_perl()
if(DEFINED QT_SYNCQT)
return()
endif()
get_property(QT_SYNCQT GLOBAL PROPERTY _qt_syncqt)
if(NOT "${QT_SYNCQT}" STREQUAL "")
set(QT_SYNCQT "${QT_SYNCQT}" PARENT_SCOPE)
return()
endif()
# When building qtbase, use the source syncqt, otherwise use the installed one.
set(SYNCQT_FROM_SOURCE "${QtBase_SOURCE_DIR}/libexec/syncqt.pl")
if(NOT ("${QtBase_SOURCE_DIR}" STREQUAL "") AND EXISTS "${SYNCQT_FROM_SOURCE}")
set(syncqt_absolute_path "${SYNCQT_FROM_SOURCE}")
message(STATUS "Using source syncqt found at: ${syncqt_absolute_path}")
qt_path_join(syncqt_install_dir ${QT_INSTALL_DIR} ${INSTALL_LIBEXECDIR})
qt_copy_or_install(PROGRAMS "${SYNCQT_FROM_SOURCE}"
DESTINATION "${syncqt_install_dir}")
elseif(NOT "${QT_HOST_PATH}" STREQUAL "")
get_filename_component(syncqt_absolute_path
"${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}/syncqt.pl"
ABSOLUTE)
message(STATUS "Using host syncqt found at: ${syncqt_absolute_path}")
else()
get_filename_component(syncqt_absolute_path
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}/syncqt.pl"
ABSOLUTE)
message(STATUS "Using installed syncqt found at: ${syncqt_absolute_path}")
endif()
set(QT_SYNCQT "${syncqt_absolute_path}" PARENT_SCOPE)
set_property(GLOBAL PROPERTY _qt_syncqt "${syncqt_absolute_path}")
endfunction()
function(qt_install_injections target build_dir install_dir)
set(injections ${ARGN})
qt_internal_module_info(module ${target})
get_target_property(target_type ${target} TYPE)
if (target_type STREQUAL "INTERFACE_LIBRARY")
set(is_framework FALSE)
else()
get_target_property(is_framework ${target} FRAMEWORK)
endif()
# examples:
# SYNCQT.INJECTIONS = src/corelib/global/qconfig.h:qconfig.h:QtConfig src/corelib/global/qconfig_p.h:5.12.0/QtCore/private/qconfig_p.h
# SYNCQT.INJECTIONS = src/gui/vulkan/qvulkanfunctions.h:^qvulkanfunctions.h:QVulkanFunctions:QVulkanDeviceFunctions src/gui/vulkan/qvulkanfunctions_p.h:^5.12.0/QtGui/private/qvulkanfunctions_p.h
# The are 3 parts to the assignment, divded by colons ':'.
# The first part contains a path to a generated file in a build folder.
# The second part contains the file name that the forwarding header should have, which points
# to the file in the first part.
# The third part contains multiple UpperCaseFileNames that should be forwarding headers to the
# header specified in the second part.
separate_arguments(injections UNIX_COMMAND "${injections}")
foreach(injection ${injections})
string(REPLACE ":" ";" injection ${injection})
# Part 1.
list(GET injection 0 file)
# Part 2.
list(GET injection 1 destination)
string(REGEX REPLACE "^\\^" "" destination "${destination}")
list(REMOVE_AT injection 0 1)
# Part 3.
set(fwd_hdrs ${injection})
get_filename_component(destinationdir ${destination} DIRECTORY)
get_filename_component(destinationname ${destination} NAME)
get_filename_component(original_file_name ${file} NAME)
# This describes a concrete example for easier comprehension:
# A file 'qtqml-config.h' is generated by qt_internal_feature_write_file into
# ${qtdeclarative_build_dir}/src/{module_include_name}/qtqml-config.h (part 1).
#
# Generate a lower case forwarding header (part 2) 'qtqml-config.h' at the following
# location:
# ${some_prefix}/include/${module_include_name}/qtqml-config.h.
#
# Inside this file, we #include the originally generated file,
# ${qtdeclarative_build_dir}/src/{module_include_name}/qtqml-config.h.
#
# ${some_prefix}'s value depends on the build type.
# If doing a prefix build, it should point to
# ${current_repo_build_dir} which is ${qtdeclarative_build_dir}.
# If doing a non-prefix build, it should point to
# ${qtbase_build_dir}.
#
# In the code below, ${some_prefix} == ${build_dir}.
set(lower_case_forwarding_header_path "${build_dir}/include/${module_include_name}")
if(destinationdir)
string(APPEND lower_case_forwarding_header_path "/${destinationdir}")
endif()
set(current_repo_build_dir "${PROJECT_BINARY_DIR}")
file(RELATIVE_PATH relpath
"${lower_case_forwarding_header_path}"
"${current_repo_build_dir}/${file}")
set(main_contents "#include \"${relpath}\"")
qt_configure_file(OUTPUT "${lower_case_forwarding_header_path}/${original_file_name}"
CONTENT "${main_contents}")
if(is_framework)
if(file MATCHES "_p\\.h$")
set(header_type PRIVATE)
else()
set(header_type PUBLIC)
endif()
qt_copy_framework_headers(${target} ${header_type}
${current_repo_build_dir}/${file})
else()
# Copy the actual injected (generated) header file (not the just created forwarding one)
# to its install location when doing a prefix build. In an non-prefix build, the qt_install
# will be a no-op.
qt_path_join(install_destination
${install_dir} ${INSTALL_INCLUDEDIR}
${module_include_name} ${destinationdir})
qt_install(FILES ${current_repo_build_dir}/${file}
DESTINATION ${install_destination}
RENAME ${destinationname} OPTIONAL)
endif()
# Generate UpperCaseNamed forwarding headers (part 3).
foreach(fwd_hdr ${fwd_hdrs})
set(upper_case_forwarding_header_path "include/${module_include_name}")
if(destinationdir)
string(APPEND upper_case_forwarding_header_path "/${destinationdir}")
endif()
# Generate upper case forwarding header like QVulkanFunctions or QtConfig.
qt_configure_file(OUTPUT "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
CONTENT "#include \"${destinationname}\"\n")
if(is_framework)
# Copy the forwarding header to the framework's Headers directory.
qt_copy_framework_headers(${target} PUBLIC
"${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}")
else()
# Install the forwarding header.
qt_path_join(install_destination "${install_dir}" "${INSTALL_INCLUDEDIR}"
${module_include_name})
qt_install(FILES "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
DESTINATION ${install_destination} OPTIONAL)
endif()
endforeach()
endforeach()
endfunction()
function(qt_read_headers_pri module_include_dir resultVarPrefix)
file(STRINGS "${module_include_dir}/headers.pri" headers_pri_contents)
foreach(line ${headers_pri_contents})
if("${line}" MATCHES "SYNCQT.HEADER_FILES = (.*)")
set(public_module_headers "${CMAKE_MATCH_1}")
separate_arguments(public_module_headers UNIX_COMMAND "${public_module_headers}")
elseif("${line}" MATCHES "SYNCQT.PRIVATE_HEADER_FILES = (.*)")
set(private_module_headers "${CMAKE_MATCH_1}")
separate_arguments(private_module_headers UNIX_COMMAND "${private_module_headers}")
elseif("${line}" MATCHES "SYNCQT.GENERATED_HEADER_FILES = (.*)")
set(generated_module_headers "${CMAKE_MATCH_1}")
separate_arguments(generated_module_headers UNIX_COMMAND "${generated_module_headers}")
foreach(generated_header ${generated_module_headers})
list(APPEND public_module_headers "${module_include_dir}/${generated_header}")
endforeach()
list(TRANSFORM generated_module_headers PREPEND "${module_include_dir}/")
elseif("${line}" MATCHES "SYNCQT.INJECTIONS = (.*)")
set(injections "${CMAKE_MATCH_1}")
elseif("${line}" MATCHES "SYNCQT.([A-Z_]+)_HEADER_FILES = (.+)")
set(prefix "${CMAKE_MATCH_1}")
string(TOLOWER "${prefix}" prefix)
set(entries "${CMAKE_MATCH_2}")
separate_arguments(entries UNIX_COMMAND "${entries}")
set("${resultVarPrefix}_${prefix}" "${entries}" PARENT_SCOPE)
endif()
endforeach()
set(${resultVarPrefix}_generated "${generated_module_headers}" PARENT_SCOPE)
set(${resultVarPrefix}_public "${public_module_headers}" PARENT_SCOPE)
set(${resultVarPrefix}_private "${private_module_headers}" PARENT_SCOPE)
set(${resultVarPrefix}_injections "${injections}" PARENT_SCOPE)
endfunction()
function(qt_compute_injection_forwarding_header target)
qt_parse_all_arguments(arg "qt_compute_injection_forwarding_header"
"PRIVATE" "SOURCE;OUT_VAR" "" ${ARGN})
qt_internal_module_info(module "${target}")
get_filename_component(file_name "${arg_SOURCE}" NAME)
set(source_absolute_path "${CMAKE_CURRENT_BINARY_DIR}/${arg_SOURCE}")
file(RELATIVE_PATH relpath "${PROJECT_BINARY_DIR}" "${source_absolute_path}")
if (arg_PRIVATE)
set(fwd "${PROJECT_VERSION}/${module_include_name}/private/${file_name}")
else()
set(fwd "${file_name}")
endif()
string(APPEND ${arg_OUT_VAR} " ${relpath}:${fwd}")
set(${arg_OUT_VAR} ${${arg_OUT_VAR}} PARENT_SCOPE)
endfunction()
# The function generates the Qt module header structure in build directory and creates install
# rules. Apart the lists of header files the function takes into account
# QT_REPO_PUBLIC_NAMESPACE_REGEX cache variable, that can be set by repository in .cmake.conf file.
@ -451,11 +245,6 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
endfunction()
function(qt_internal_collect_sync_header_dependencies out_var skip_non_existing)
if(NOT QT_USE_SYNCQT_CPP)
set(${out_var} "" PARENT_SCOPE)
return()
endif()
list(LENGTH ARGN sync_headers_target_count)
if(sync_headers_target_count EQUAL 0)
message(FATAL_ERROR "Invalid use of qt_internal_collect_sync_header_dependencies,"

View File

@ -27,7 +27,7 @@
QT_BEGIN_NAMESPACE
#define Q_DBUS_NO_EXPORT // force findclasslist.pl looking into this namespace
#define Q_DBUS_NO_EXPORT // force syncqt looking into this namespace
namespace Q_DBUS_NO_EXPORT QDBusUtil
{
Q_DBUS_EXPORT bool isValidInterfaceName(const QString &ifaceName);

View File

@ -4,6 +4,11 @@
#ifndef MODULE_API_H
#define MODULE_API_H
#if 0
#pragma qt_sync_skip_header_check
#pragma qt_sync_stop_processing
#endif
#include <QtTestAutogeneratingCppExports/qttestautogeneratingcppexportsexports.h>
struct Q_TESTAUTOGENERATINGCPPEXPORTS_EXPORT TestApi

View File

@ -4,6 +4,11 @@
#ifndef MODULE_API_H
#define MODULE_API_H
#if 0
#pragma qt_sync_skip_header_check
#pragma qt_sync_stop_processing
#endif
#include <QtTestAutogeneratingCppExportsCustomName/customname_exports.h>
struct Q_TESTAUTOGENERATINGCPPEXPORTSCUSTOMNAME_EXPORT TestApi