Add "content file" mode for the qt_internal_add_linker_version_script
Add the support of pre-cooked content for the LD version script. The content can be generated without using the perl script at configure or build time. Change-Id: I1316e114a1d5550b2fdcf3482a51f336fb311a29 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
ad6aaa7727
commit
5a5ad8c002
@ -238,6 +238,7 @@ qt_copy_or_install(FILES
|
||||
cmake/QtGenerateExtPri.cmake
|
||||
cmake/QtGenerateLibHelpers.cmake
|
||||
cmake/QtGenerateLibPri.cmake
|
||||
cmake/QtGenerateVersionScript.cmake
|
||||
cmake/QtGlobalStateHelpers.cmake
|
||||
cmake/QtHeadersClean.cmake
|
||||
cmake/QtInstallHelpers.cmake
|
||||
|
@ -1,14 +1,34 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
# 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)
|
||||
qt_parse_all_arguments(arg "qt_internal_add_linker" "" "" "PRIVATE_HEADERS" ${ARGN})
|
||||
qt_parse_all_arguments(arg "qt_internal_add_linker_version_script"
|
||||
""
|
||||
"PRIVATE_CONTENT_FILE"
|
||||
"PRIVATE_HEADERS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if (TEST_ld_version_script)
|
||||
if(arg_PRIVATE_CONTENT_FILE AND arg_PRIVATE_HEADERS)
|
||||
message(FATAL_ERROR "Both PRIVATE_CONTENT_FILE and PRIVATE_HEADERS are specified.")
|
||||
endif()
|
||||
|
||||
if(TEST_ld_version_script)
|
||||
set(contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API {\n qt_private_api_tag*;\n")
|
||||
foreach(ph ${arg_PRIVATE_HEADERS})
|
||||
string(APPEND contents " @FILE:${ph}@\n")
|
||||
endforeach()
|
||||
if(arg_PRIVATE_HEADERS)
|
||||
foreach(ph ${arg_PRIVATE_HEADERS})
|
||||
string(APPEND contents " @FILE:${ph}@\n")
|
||||
endforeach()
|
||||
else()
|
||||
string(APPEND contents "@PRIVATE_CONTENT@")
|
||||
endif()
|
||||
string(APPEND contents "};\n")
|
||||
set(current "Qt_${PROJECT_VERSION_MAJOR}")
|
||||
if (QT_NAMESPACE STREQUAL "")
|
||||
@ -33,16 +53,31 @@ function(qt_internal_add_linker_version_script target)
|
||||
|
||||
file(GENERATE OUTPUT "${infile}" CONTENT "${contents}")
|
||||
|
||||
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"
|
||||
)
|
||||
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"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${outfile}"
|
||||
|
15
cmake/QtGenerateVersionScript.cmake
Normal file
15
cmake/QtGenerateVersionScript.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(EXISTS "${PRIVATE_CONTENT_FILE}")
|
||||
file(READ "${PRIVATE_CONTENT_FILE}" PRIVATE_CONTENT)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${IN_FILE}")
|
||||
message(FATAL_ERROR "Input file ${IN_FILE} doesn't exists")
|
||||
endif()
|
||||
|
||||
if(OUT_FILE STREQUAL "")
|
||||
message(FATAL_ERROR "Output file is not specified")
|
||||
endif()
|
||||
|
||||
configure_file("${IN_FILE}" "${OUT_FILE}" @ONLY)
|
Loading…
Reference in New Issue
Block a user