CMake: Rename internal functions to contain qt_internal

Offer compatibility wrapper functions until we update all of the Qt
repos to use the new names.

Task-number: QTBUG-86815
Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Alexandru Croitor 2020-09-22 10:02:27 +02:00
parent 6f0a9df8d2
commit e0c62a48b8
13 changed files with 162 additions and 75 deletions

View File

@ -1,6 +1,6 @@
# Wrapper function to create a regular cmake target and forward all the # Wrapper function to create a regular cmake target and forward all the
# arguments collected by the conversion script. This is only meant for tests! # arguments collected by the conversion script. This is only meant for tests!
function(qt_add_cmake_library target) function(qt_internal_add_cmake_library target)
# Process arguments: # Process arguments:
qt_parse_all_arguments(arg "qt_add_cmake_library" qt_parse_all_arguments(arg "qt_add_cmake_library"
"SHARED;MODULE;STATIC;INTERFACE" "SHARED;MODULE;STATIC;INTERFACE"
@ -58,7 +58,7 @@ function(qt_add_cmake_library target)
) )
endif() endif()
qt_extend_target("${target}" qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES} SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES} ${arg_INCLUDE_DIRECTORIES}
@ -84,7 +84,7 @@ endfunction()
# This function replaces qmake's qt_helper_lib feature. It is intended to # This function replaces qmake's qt_helper_lib feature. It is intended to
# compile 3rdparty libraries as part of the build. # compile 3rdparty libraries as part of the build.
# #
function(qt_add_3rdparty_library target) function(qt_internal_add_3rdparty_library target)
# Process arguments: # Process arguments:
qt_parse_all_arguments(arg "qt_add_3rdparty_library" qt_parse_all_arguments(arg "qt_add_3rdparty_library"
"SHARED;MODULE;STATIC;INTERFACE;EXCEPTIONS;INSTALL;SKIP_AUTOMOC" "SHARED;MODULE;STATIC;INTERFACE;EXCEPTIONS;INSTALL;SKIP_AUTOMOC"
@ -173,7 +173,7 @@ function(qt_add_3rdparty_library target)
qt_install(FILES "${pri_file}" DESTINATION "${INSTALL_MKSPECSDIR}/modules") qt_install(FILES "${pri_file}" DESTINATION "${INSTALL_MKSPECSDIR}/modules")
endif() endif()
qt_extend_target("${target}" qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES} SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES} ${arg_INCLUDE_DIRECTORIES}

View File

@ -15,7 +15,7 @@ function(qt_internal_add_app target)
set(no_install NO_INSTALL) set(no_install NO_INSTALL)
endif() endif()
qt_add_executable("${target}" qt_internal_add_executable("${target}"
DELAY_RC DELAY_RC
DELAY_TARGET_INFO DELAY_TARGET_INFO
OUTPUT_DIRECTORY "${output_directory}" OUTPUT_DIRECTORY "${output_directory}"

View File

@ -1,52 +1,112 @@
# Compatibility macros that should be removed once all their usages are removed. if(NOT QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS)
function(extend_target) # Compatibility functions that should be removed once all their usages are removed.
function(extend_target)
qt_extend_target(${ARGV}) qt_extend_target(${ARGV})
endfunction() endfunction()
function(add_qt_module) function(add_qt_module)
qt_add_module(${ARGV}) qt_add_module(${ARGV})
endfunction() endfunction()
function(add_qt_plugin) function(add_qt_plugin)
qt_add_plugin(${ARGV}) qt_add_plugin(${ARGV})
endfunction() endfunction()
function(add_qt_tool) function(add_qt_tool)
qt_add_tool(${ARGV}) qt_add_tool(${ARGV})
endfunction() endfunction()
function(add_qt_test) function(add_qt_test)
qt_add_test(${ARGV}) qt_add_test(${ARGV})
endfunction() endfunction()
function(add_qt_test_helper) function(add_qt_test_helper)
qt_add_test_helper(${ARGV}) qt_add_test_helper(${ARGV})
endfunction() endfunction()
function(add_qt_manual_test) function(add_qt_manual_test)
qt_add_manual_test(${ARGV}) qt_add_manual_test(${ARGV})
endfunction() endfunction()
function(add_qt_benchmark) function(add_qt_benchmark)
qt_add_benchmark(${ARGV}) qt_add_benchmark(${ARGV})
endfunction() endfunction()
function(add_qt_executable) function(add_qt_executable)
qt_add_executable(${ARGV}) qt_add_executable(${ARGV})
endfunction() endfunction()
function(add_qt_simd_part) function(add_qt_simd_part)
qt_add_simd_part(${ARGV}) qt_add_simd_part(${ARGV})
endfunction() endfunction()
function(add_qt_docs) function(add_qt_docs)
qt_add_docs(${ARGV}) qt_add_docs(${ARGV})
endfunction() endfunction()
function(add_qt_resource) function(add_qt_resource)
qt_add_resource(${ARGV}) qt_add_resource(${ARGV})
endfunction() endfunction()
function(add_cmake_library) function(add_cmake_library)
qt_add_cmake_library(${ARGV}) qt_add_cmake_library(${ARGV})
endfunction() endfunction()
# New compatibility functions that should be removed before release.
function(qt_extend_target)
qt_internal_extend_target(${ARGV})
endfunction()
function(qt_add_module)
qt_internal_add_module(${ARGV})
endfunction()
function(qt_add_tool)
qt_internal_add_tool(${ARGV})
endfunction()
function(qt_add_test)
qt_internal_add_test(${ARGV})
endfunction()
function(qt_add_test_helper)
qt_internal_add_test_helper(${ARGV})
endfunction()
function(qt_add_manual_test)
qt_internal_add_manual_test(${ARGV})
endfunction()
function(qt_add_benchmark)
qt_internal_add_benchmark(${ARGV})
endfunction()
function(qt_add_executable)
qt_internal_add_executable(${ARGV})
endfunction()
function(qt_add_simd_part)
qt_internal_add_simd_part(${ARGV})
endfunction()
function(qt_add_docs)
qt_internal_add_docs(${ARGV})
endfunction()
function(qt_add_resource)
qt_internal_add_resource(${ARGV})
endfunction()
function(qt_add_cmake_library)
qt_internal_add_cmake_library(${ARGV})
endfunction()
function(qt_add_3rdparty_library)
qt_internal_add_3rdparty_library(${ARGV})
endfunction()
function(qt_create_tracepoints)
qt_internal_create_tracepoints(${ARGV})
endfunction()
endif()

View File

@ -1,4 +1,4 @@
function(qt_add_docs) function(qt_internal_add_docs)
if(${ARGC} EQUAL 1) if(${ARGC} EQUAL 1)
# Function called from old generated CMakeLists.txt that was missing the target parameter # Function called from old generated CMakeLists.txt that was missing the target parameter
return() return()

View File

@ -1,7 +1,7 @@
# This function creates a CMake target for a generic console or GUI binary. # This function creates a CMake target for a generic console or GUI binary.
# Please consider to use a more specific version target like the one created # Please consider to use a more specific version target like the one created
# by qt_add_test or qt_add_tool below. # by qt_add_test or qt_add_tool below.
function(qt_add_executable name) function(qt_internal_add_executable name)
qt_parse_all_arguments(arg "qt_add_executable" qt_parse_all_arguments(arg "qt_add_executable"
"${__qt_add_executable_optional_args}" "${__qt_add_executable_optional_args}"
"${__qt_add_executable_single_args}" "${__qt_add_executable_single_args}"
@ -86,7 +86,7 @@ function(qt_add_executable name)
${arg_INCLUDE_DIRECTORIES} ${arg_INCLUDE_DIRECTORIES}
) )
qt_extend_target("${name}" qt_internal_extend_target("${name}"
SOURCES ${arg_SOURCES} SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES ${private_includes} INCLUDE_DIRECTORIES ${private_includes}
DEFINES ${arg_DEFINES} DEFINES ${arg_DEFINES}

View File

@ -8,7 +8,7 @@
# this module are imported into the scope of the calling feature. # this module are imported into the scope of the calling feature.
# #
# Target is without leading "Qt". So e.g. the "QtCore" module has the target "Core". # Target is without leading "Qt". So e.g. the "QtCore" module has the target "Core".
function(qt_add_module target) function(qt_internal_add_module target)
qt_internal_module_info(module "${target}") qt_internal_module_info(module "${target}")
# Process arguments: # Process arguments:
@ -327,7 +327,7 @@ function(qt_add_module target)
) )
endif() endif()
qt_extend_target("${target}" qt_internal_extend_target("${target}"
${header_module} ${header_module}
SOURCES ${arg_SOURCES} SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES

View File

@ -155,7 +155,7 @@ function(qt_internal_add_plugin target)
${arg_PUBLIC_INCLUDE_DIRECTORIES} ${arg_PUBLIC_INCLUDE_DIRECTORIES}
) )
qt_extend_target("${target}" qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES} SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
${private_includes} ${private_includes}

View File

@ -1,4 +1,4 @@
function(qt_add_resource target resourceName) function(qt_internal_add_resource target resourceName)
# Don't try to add resources when cross compiling, and the target is actually a host target # Don't try to add resources when cross compiling, and the target is actually a host target
# (like a tool). # (like a tool).
qt_is_imported_target("${target}" is_imported) qt_is_imported_target("${target}" is_imported)

View File

@ -1,7 +1,7 @@
# Handle files that need special SIMD-related flags. # Handle files that need special SIMD-related flags.
# This creates an object library and makes target link # This creates an object library and makes target link
# to it (privately). # to it (privately).
function(qt_add_simd_part target) function(qt_internal_add_simd_part target)
qt_parse_all_arguments(arg "qt_add_simd_part" "" "" qt_parse_all_arguments(arg "qt_add_simd_part" "" ""
"NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN}) "NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN})
if ("x${arg_SIMD}" STREQUAL x) if ("x${arg_SIMD}" STREQUAL x)

View File

@ -1,6 +1,6 @@
# This function can be used to add sources/libraries/etc. to the specified CMake target # This function can be used to add sources/libraries/etc. to the specified CMake target
# if the provided CONDITION evaluates to true. # if the provided CONDITION evaluates to true.
function(qt_extend_target target) function(qt_internal_extend_target target)
# Don't try to extend_target when cross compiling an imported host target (like a tool). # Don't try to extend_target when cross compiling an imported host target (like a tool).
qt_is_imported_target("${target}" is_imported) qt_is_imported_target("${target}" is_imported)
if(is_imported) if(is_imported)
@ -326,7 +326,7 @@ function(qt_internal_export_modern_cmake_config_targets_file)
qt_install(EXPORT ${export_name} NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}") qt_install(EXPORT ${export_name} NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}")
endfunction() endfunction()
function(qt_create_tracepoints name tracepoints_file) function(qt_internal_create_tracepoints name tracepoints_file)
string(TOLOWER "${name}" provider_name) string(TOLOWER "${name}" provider_name)
string(PREPEND provider_name "qt") string(PREPEND provider_name "qt")
set(header_filename "${provider_name}_tracepoints_p.h") set(header_filename "${provider_name}_tracepoints_p.h")

View File

@ -1,7 +1,7 @@
# Simple wrapper around qt_add_executable for benchmarks which insure that # Simple wrapper around qt_add_executable for benchmarks which insure that
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed. # the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
# See qt_add_executable() for more details. # See qt_add_executable() for more details.
function(qt_add_benchmark target) function(qt_internal_add_benchmark target)
qt_parse_all_arguments(arg "qt_add_benchmark" qt_parse_all_arguments(arg "qt_add_benchmark"
"${__qt_add_executable_optional_args}" "${__qt_add_executable_optional_args}"
@ -38,7 +38,7 @@ endfunction()
# Simple wrapper around qt_add_executable for manual tests which insure that # Simple wrapper around qt_add_executable for manual tests which insure that
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed. # the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
# See qt_add_executable() for more details. # See qt_add_executable() for more details.
function(qt_add_manual_test target) function(qt_internal_add_manual_test target)
qt_parse_all_arguments(arg "qt_add_manual_test" qt_parse_all_arguments(arg "qt_add_manual_test"
"${__qt_add_executable_optional_args}" "${__qt_add_executable_optional_args}"
@ -141,7 +141,7 @@ function(qt_internal_setup_docker_test_fixture name)
endfunction() endfunction()
# This function creates a CMake test target with the specified name for use with CTest. # This function creates a CMake test target with the specified name for use with CTest.
function(qt_add_test name) function(qt_internal_add_test name)
qt_parse_all_arguments(arg "qt_add_test" qt_parse_all_arguments(arg "qt_add_test"
"RUN_SERIAL;EXCEPTIONS;GUI;QMLTEST;CATCH;LOWDPI" "RUN_SERIAL;EXCEPTIONS;GUI;QMLTEST;CATCH;LOWDPI"
"OUTPUT_DIRECTORY;WORKING_DIRECTORY;TIMEOUT;VERSION" "OUTPUT_DIRECTORY;WORKING_DIRECTORY;TIMEOUT;VERSION"
@ -173,7 +173,7 @@ function(qt_add_test name)
${arg_INCLUDE_DIRECTORIES} ${arg_INCLUDE_DIRECTORIES}
) )
qt_add_executable("${name}" qt_internal_add_executable("${name}"
${exceptions_text} ${exceptions_text}
${gui_text} ${gui_text}
${version_arg} ${version_arg}
@ -205,16 +205,16 @@ function(qt_add_test name)
# QMLTest specifics # QMLTest specifics
qt_extend_target("${name}" CONDITION arg_QMLTEST qt_internal_extend_target("${name}" CONDITION arg_QMLTEST
PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest
) )
qt_extend_target("${name}" CONDITION arg_QMLTEST AND NOT ANDROID qt_internal_extend_target("${name}" CONDITION arg_QMLTEST AND NOT ANDROID
DEFINES DEFINES
QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
) )
qt_extend_target("${name}" CONDITION arg_QMLTEST AND ANDROID qt_internal_extend_target("${name}" CONDITION arg_QMLTEST AND ANDROID
DEFINES DEFINES
QUICK_TEST_SOURCE_DIR=":/" QUICK_TEST_SOURCE_DIR=":/"
) )
@ -377,7 +377,7 @@ endfunction()
# tests launch separate programs to test certain input/output behavior. # tests launch separate programs to test certain input/output behavior.
# Specify OVERRIDE_OUTPUT_DIRECTORY if you dont' want to place the helper in the parent directory, # Specify OVERRIDE_OUTPUT_DIRECTORY if you dont' want to place the helper in the parent directory,
# in which case you should specify OUTPUT_DIRECTORY "/foo/bar" manually. # in which case you should specify OUTPUT_DIRECTORY "/foo/bar" manually.
function(qt_add_test_helper name) function(qt_internal_add_test_helper name)
set(qt_add_test_helper_optional_args set(qt_add_test_helper_optional_args
"OVERRIDE_OUTPUT_DIRECTORY" "OVERRIDE_OUTPUT_DIRECTORY"
@ -407,5 +407,5 @@ function(qt_add_test_helper name)
set(extra_args_to_pass OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/..") set(extra_args_to_pass OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/..")
endif() endif()
qt_add_executable("${name}" NO_INSTALL ${extra_args_to_pass} ${forward_args}) qt_internal_add_executable("${name}" NO_INSTALL ${extra_args_to_pass} ${forward_args})
endfunction() endfunction()

View File

@ -7,7 +7,7 @@
# qt_get_tool_target_name(target_name my_tool) # qt_get_tool_target_name(target_name my_tool)
# qt_add_tool(${target_name}) # qt_add_tool(${target_name})
# #
function(qt_add_tool target_name) function(qt_internal_add_tool target_name)
qt_tool_target_to_name(name ${target_name}) qt_tool_target_to_name(name ${target_name})
qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL" qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL"
"TOOLS_TARGET;${__default_target_info_args}" "TOOLS_TARGET;${__default_target_info_args}"
@ -115,7 +115,7 @@ function(qt_add_tool target_name)
set(no_qt NO_QT) set(no_qt NO_QT)
endif() endif()
qt_add_executable("${target_name}" OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}" qt_internal_add_executable("${target_name}" OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
${bootstrap} ${bootstrap}
${no_qt} ${no_qt}
NO_INSTALL NO_INSTALL

View File

@ -336,6 +336,7 @@ def set_up_cmake_api_calls():
api[1]["qt_add_qml_module"] = "add_qml_module" api[1]["qt_add_qml_module"] = "add_qml_module"
api[1]["qt_add_cmake_library"] = "add_cmake_library" api[1]["qt_add_cmake_library"] = "add_cmake_library"
api[1]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library" api[1]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library"
api[1]["qt_create_tracepoints"] = "qt_create_tracepoints"
api[2]["qt_extend_target"] = "qt_extend_target" api[2]["qt_extend_target"] = "qt_extend_target"
api[2]["qt_add_module"] = "qt_add_module" api[2]["qt_add_module"] = "qt_add_module"
@ -353,6 +354,25 @@ def set_up_cmake_api_calls():
api[2]["qt_add_qml_module"] = "qt_add_qml_module" api[2]["qt_add_qml_module"] = "qt_add_qml_module"
api[2]["qt_add_cmake_library"] = "qt_add_cmake_library" api[2]["qt_add_cmake_library"] = "qt_add_cmake_library"
api[2]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library" api[2]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library"
api[2]["qt_create_tracepoints"] = "qt_create_tracepoints"
api[3]["qt_extend_target"] = "qt_internal_extend_target"
api[3]["qt_add_module"] = "qt_internal_add_module"
api[3]["qt_add_plugin"] = "qt_internal_add_plugin"
api[3]["qt_add_tool"] = "qt_internal_add_tool"
api[3]["qt_internal_add_app"] = "qt_internal_add_app"
api[3]["qt_add_test"] = "qt_internal_add_test"
api[3]["qt_add_test_helper"] = "qt_internal_add_test_helper"
api[3]["qt_add_manual_test"] = "qt_internal_add_manual_test"
api[3]["qt_add_benchmark"] = "qt_internal_add_benchmark"
api[3]["qt_add_executable"] = "qt_internal_add_executable"
api[3]["qt_add_simd_part"] = "qt_internal_add_simd_part"
api[3]["qt_add_docs"] = "qt_internal_add_docs"
api[3]["qt_add_resource"] = "qt_internal_add_resource"
api[3]["qt_add_qml_module"] = "qt_internal_add_qml_module"
api[3]["qt_add_cmake_library"] = "qt_internal_add_cmake_library"
api[3]["qt_add_3rdparty_library"] = "qt_internal_add_3rdparty_library"
api[3]["qt_create_tracepoints"] = "qt_internal_create_tracepoints"
return api return api
@ -372,15 +392,21 @@ def detect_cmake_api_version_used_in_file_content(project_file_path: str) -> Opt
with open(cmake_project_path, "r") as file_fd: with open(cmake_project_path, "r") as file_fd:
contents = file_fd.read() contents = file_fd.read()
new_api_calls = [cmake_api_calls[2][api_call] for api_call in cmake_api_calls[2]] api_call_versions = [version for version in cmake_api_calls]
new_api_calls_alternatives = "|".join(new_api_calls) api_call_versions = sorted(api_call_versions, reverse=True)
match = re.search(new_api_calls_alternatives, contents) api_call_version_matches = {}
for version in api_call_versions:
versioned_api_calls = [cmake_api_calls[version][api_call]
for api_call in cmake_api_calls[version]]
versioned_api_calls_alternatives = "|".join(versioned_api_calls)
api_call_version_matches[version] = re.search(versioned_api_calls_alternatives, contents)
# If new style found, return latest api version. Otherwise # If new style found, return latest api version. Otherwise
# the old version. # return the current version.
if match: for version in api_call_version_matches:
return 2 if api_call_version_matches[version]:
else: return version
return 1 return 1
@ -3346,8 +3372,9 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
if "qt_tracepoints" in scope.get("CONFIG"): if "qt_tracepoints" in scope.get("CONFIG"):
tracepoints = scope.get_files("TRACEPOINT_PROVIDER") tracepoints = scope.get_files("TRACEPOINT_PROVIDER")
create_trace_points = get_cmake_api_call("qt_create_tracepoints")
cm_fh.write( cm_fh.write(
f"\n\n{spaces(indent)}qt_create_tracepoints({module_name[2:]} {' '.join(tracepoints)})\n" f"\n\n{spaces(indent)}{create_trace_points}({module_name[2:]} {' '.join(tracepoints)})\n"
) )
return target_name return target_name