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:
parent
6f0a9df8d2
commit
e0c62a48b8
@ -1,6 +1,6 @@
|
||||
# Wrapper function to create a regular cmake target and forward all the
|
||||
# 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:
|
||||
qt_parse_all_arguments(arg "qt_add_cmake_library"
|
||||
"SHARED;MODULE;STATIC;INTERFACE"
|
||||
@ -58,7 +58,7 @@ function(qt_add_cmake_library target)
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_extend_target("${target}"
|
||||
qt_internal_extend_target("${target}"
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
@ -84,7 +84,7 @@ endfunction()
|
||||
# This function replaces qmake's qt_helper_lib feature. It is intended to
|
||||
# compile 3rdparty libraries as part of the build.
|
||||
#
|
||||
function(qt_add_3rdparty_library target)
|
||||
function(qt_internal_add_3rdparty_library target)
|
||||
# Process arguments:
|
||||
qt_parse_all_arguments(arg "qt_add_3rdparty_library"
|
||||
"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")
|
||||
endif()
|
||||
|
||||
qt_extend_target("${target}"
|
||||
qt_internal_extend_target("${target}"
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
|
@ -15,7 +15,7 @@ function(qt_internal_add_app target)
|
||||
set(no_install NO_INSTALL)
|
||||
endif()
|
||||
|
||||
qt_add_executable("${target}"
|
||||
qt_internal_add_executable("${target}"
|
||||
DELAY_RC
|
||||
DELAY_TARGET_INFO
|
||||
OUTPUT_DIRECTORY "${output_directory}"
|
||||
|
@ -1,52 +1,112 @@
|
||||
# Compatibility macros that should be removed once all their usages are removed.
|
||||
function(extend_target)
|
||||
qt_extend_target(${ARGV})
|
||||
endfunction()
|
||||
if(NOT QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS)
|
||||
# Compatibility functions that should be removed once all their usages are removed.
|
||||
function(extend_target)
|
||||
qt_extend_target(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_module)
|
||||
qt_add_module(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_module)
|
||||
qt_add_module(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_plugin)
|
||||
qt_add_plugin(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_plugin)
|
||||
qt_add_plugin(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_tool)
|
||||
qt_add_tool(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_tool)
|
||||
qt_add_tool(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_test)
|
||||
qt_add_test(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_test)
|
||||
qt_add_test(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_test_helper)
|
||||
qt_add_test_helper(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_test_helper)
|
||||
qt_add_test_helper(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_manual_test)
|
||||
qt_add_manual_test(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_manual_test)
|
||||
qt_add_manual_test(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_benchmark)
|
||||
qt_add_benchmark(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_benchmark)
|
||||
qt_add_benchmark(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_executable)
|
||||
qt_add_executable(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_executable)
|
||||
qt_add_executable(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_simd_part)
|
||||
qt_add_simd_part(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_simd_part)
|
||||
qt_add_simd_part(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_docs)
|
||||
qt_add_docs(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_docs)
|
||||
qt_add_docs(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_qt_resource)
|
||||
qt_add_resource(${ARGV})
|
||||
endfunction()
|
||||
function(add_qt_resource)
|
||||
qt_add_resource(${ARGV})
|
||||
endfunction()
|
||||
|
||||
function(add_cmake_library)
|
||||
qt_add_cmake_library(${ARGV})
|
||||
endfunction()
|
||||
function(add_cmake_library)
|
||||
qt_add_cmake_library(${ARGV})
|
||||
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()
|
||||
|
@ -1,4 +1,4 @@
|
||||
function(qt_add_docs)
|
||||
function(qt_internal_add_docs)
|
||||
if(${ARGC} EQUAL 1)
|
||||
# Function called from old generated CMakeLists.txt that was missing the target parameter
|
||||
return()
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 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
|
||||
# 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_add_executable_optional_args}"
|
||||
"${__qt_add_executable_single_args}"
|
||||
@ -86,7 +86,7 @@ function(qt_add_executable name)
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
qt_extend_target("${name}"
|
||||
qt_internal_extend_target("${name}"
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES ${private_includes}
|
||||
DEFINES ${arg_DEFINES}
|
||||
|
@ -8,7 +8,7 @@
|
||||
# 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".
|
||||
function(qt_add_module target)
|
||||
function(qt_internal_add_module target)
|
||||
qt_internal_module_info(module "${target}")
|
||||
|
||||
# Process arguments:
|
||||
@ -327,7 +327,7 @@ function(qt_add_module target)
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_extend_target("${target}"
|
||||
qt_internal_extend_target("${target}"
|
||||
${header_module}
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES
|
||||
|
@ -155,7 +155,7 @@ function(qt_internal_add_plugin target)
|
||||
${arg_PUBLIC_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
qt_extend_target("${target}"
|
||||
qt_internal_extend_target("${target}"
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES
|
||||
${private_includes}
|
||||
|
@ -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
|
||||
# (like a tool).
|
||||
qt_is_imported_target("${target}" is_imported)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Handle files that need special SIMD-related flags.
|
||||
# This creates an object library and makes target link
|
||||
# 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" "" ""
|
||||
"NAME;SIMD;${__default_private_args};COMPILE_FLAGS" ${ARGN})
|
||||
if ("x${arg_SIMD}" STREQUAL x)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This function can be used to add sources/libraries/etc. to the specified CMake target
|
||||
# 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).
|
||||
qt_is_imported_target("${target}" 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}")
|
||||
endfunction()
|
||||
|
||||
function(qt_create_tracepoints name tracepoints_file)
|
||||
function(qt_internal_create_tracepoints name tracepoints_file)
|
||||
string(TOLOWER "${name}" provider_name)
|
||||
string(PREPEND provider_name "qt")
|
||||
set(header_filename "${provider_name}_tracepoints_p.h")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Simple wrapper around qt_add_executable for benchmarks which insure that
|
||||
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
|
||||
# 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_add_executable_optional_args}"
|
||||
@ -38,7 +38,7 @@ endfunction()
|
||||
# Simple wrapper around qt_add_executable for manual tests which insure that
|
||||
# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
|
||||
# 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_add_executable_optional_args}"
|
||||
@ -141,7 +141,7 @@ function(qt_internal_setup_docker_test_fixture name)
|
||||
endfunction()
|
||||
|
||||
# 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"
|
||||
"RUN_SERIAL;EXCEPTIONS;GUI;QMLTEST;CATCH;LOWDPI"
|
||||
"OUTPUT_DIRECTORY;WORKING_DIRECTORY;TIMEOUT;VERSION"
|
||||
@ -173,7 +173,7 @@ function(qt_add_test name)
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
qt_add_executable("${name}"
|
||||
qt_internal_add_executable("${name}"
|
||||
${exceptions_text}
|
||||
${gui_text}
|
||||
${version_arg}
|
||||
@ -205,16 +205,16 @@ function(qt_add_test name)
|
||||
|
||||
# QMLTest specifics
|
||||
|
||||
qt_extend_target("${name}" CONDITION arg_QMLTEST
|
||||
qt_internal_extend_target("${name}" CONDITION arg_QMLTEST
|
||||
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
|
||||
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
|
||||
QUICK_TEST_SOURCE_DIR=":/"
|
||||
)
|
||||
@ -377,7 +377,7 @@ endfunction()
|
||||
# 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,
|
||||
# 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
|
||||
"OVERRIDE_OUTPUT_DIRECTORY"
|
||||
@ -407,5 +407,5 @@ function(qt_add_test_helper name)
|
||||
set(extra_args_to_pass OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/..")
|
||||
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()
|
||||
|
@ -7,7 +7,7 @@
|
||||
# qt_get_tool_target_name(target_name my_tool)
|
||||
# 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_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL"
|
||||
"TOOLS_TARGET;${__default_target_info_args}"
|
||||
@ -115,7 +115,7 @@ function(qt_add_tool target_name)
|
||||
set(no_qt NO_QT)
|
||||
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}
|
||||
${no_qt}
|
||||
NO_INSTALL
|
||||
|
@ -336,6 +336,7 @@ def set_up_cmake_api_calls():
|
||||
api[1]["qt_add_qml_module"] = "add_qml_module"
|
||||
api[1]["qt_add_cmake_library"] = "add_cmake_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_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_cmake_library"] = "qt_add_cmake_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
|
||||
|
||||
@ -372,16 +392,22 @@ def detect_cmake_api_version_used_in_file_content(project_file_path: str) -> Opt
|
||||
with open(cmake_project_path, "r") as file_fd:
|
||||
contents = file_fd.read()
|
||||
|
||||
new_api_calls = [cmake_api_calls[2][api_call] for api_call in cmake_api_calls[2]]
|
||||
new_api_calls_alternatives = "|".join(new_api_calls)
|
||||
match = re.search(new_api_calls_alternatives, contents)
|
||||
api_call_versions = [version for version in cmake_api_calls]
|
||||
api_call_versions = sorted(api_call_versions, reverse=True)
|
||||
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
|
||||
# the old version.
|
||||
if match:
|
||||
return 2
|
||||
else:
|
||||
return 1
|
||||
# return the current version.
|
||||
for version in api_call_version_matches:
|
||||
if api_call_version_matches[version]:
|
||||
return version
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def get_cmake_api_call(api_name: str, api_version: Optional[int] = None) -> str:
|
||||
@ -3346,8 +3372,9 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
||||
|
||||
if "qt_tracepoints" in scope.get("CONFIG"):
|
||||
tracepoints = scope.get_files("TRACEPOINT_PROVIDER")
|
||||
create_trace_points = get_cmake_api_call("qt_create_tracepoints")
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user