Skip to content

Commit

Permalink
Remove perl related functionality from CMake files
Browse files Browse the repository at this point in the history
Avoid using perl in CMake scripts. Remove the syncqt.pl specific
code.

Task-number: QTBUG-87480
Change-Id: I7fcd5cc83d173ec463c275b5b50b84f25044a118
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
semlanik committed Nov 29, 2022
1 parent 5a72b32 commit 7f4aa1a
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 381 deletions.
4 changes: 0 additions & 4 deletions cmake/QtBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 0 additions & 13 deletions cmake/QtCMakeVersionHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions cmake/QtDocsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if(NOT TARGET sync_all_public_headers)
add_custom_target(sync_all_public_headers)
endif()
add_dependencies(prepare_docs_${target} sync_all_public_headers)

# generate docs target
set(generate_qdoc_args
Expand Down
16 changes: 0 additions & 16 deletions cmake/QtFeature.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
38 changes: 12 additions & 26 deletions cmake/QtFlagHandlingHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -57,31 +55,19 @@ 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()
set(generator_command ${CMAKE_COMMAND}
"-DIN_FILE=${infile}"
"-DPRIVATE_CONTENT_FILE=${arg_PRIVATE_CONTENT_FILE}"
"-DOUT_FILE=${outfile}"
-P "${QT_CMAKE_DIR}/QtGenerateVersionScript.cmake"
)
set(generator_dependencies
"${arg_PRIVATE_CONTENT_FILE}"
"${QT_CMAKE_DIR}/QtGenerateVersionScript.cmake"
)
if(NOT arg_PRIVATE_CONTENT_FILE)
set(arg_PRIVATE_CONTENT_FILE "")
endif()
set(generator_command ${CMAKE_COMMAND}
"-DIN_FILE=${infile}"
"-DPRIVATE_CONTENT_FILE=${arg_PRIVATE_CONTENT_FILE}"
"-DOUT_FILE=${outfile}"
-P "${QT_CMAKE_DIR}/QtGenerateVersionScript.cmake"
)
set(generator_dependencies
"${arg_PRIVATE_CONTENT_FILE}"
"${QT_CMAKE_DIR}/QtGenerateVersionScript.cmake"
)

add_custom_command(
OUTPUT "${outfile}"
Expand Down
11 changes: 3 additions & 8 deletions cmake/QtHeadersClean.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(header_check_exceptions
"${CMAKE_CURRENT_BINARY_DIR}/${module}_header_check_exceptions")
set(headers_check_parameters
"${CMAKE_CURRENT_BINARY_DIR}/${module_target}HeadersCheckParameters${config_suffix}.cmake")
string(JOIN "\n" headers_check_parameters_content
Expand All @@ -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()
set(sync_headers_dep "sync_headers")

foreach(header ${hclean_headers})
# We need realpath here to make sure path starts with drive letter
Expand Down
111 changes: 14 additions & 97 deletions cmake/QtModuleHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
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}")
# 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.
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -925,22 +855,15 @@ 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}")
get_target_property(module_depends_header ${target} _qt_module_depends_header)
qt_internal_install_module_headers(${target}
PUBLIC ${module_headers_public} "${module_depends_header}"
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_internal_add_headersclean_target(${target} "${module_headers_public}")
qt_internal_target_sync_headers(${target} "${module_headers_all}"
"${module_headers_generated}")
get_target_property(module_depends_header ${target} _qt_module_depends_header)
qt_internal_install_module_headers(${target}
PUBLIC ${module_headers_public} "${module_depends_header}"
PRIVATE ${module_headers_private}
QPA ${module_headers_qpa}
)

qt_finalize_framework_headers_copy(${target})
qt_generate_prl_file(${target} "${INSTALL_LIBDIR}")
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 7f4aa1a

Please sign in to comment.