summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-09-15 11:46:16 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2022-09-21 14:00:37 +0200
commit0b59c204a4d23d86a0c6dd4f265e4186c633dd98 (patch)
tree0d774aee29a71f7c57f8a8cfd47230d75d6ca907 /cmake
parent00b9409843c1a0934aca5082d0ef41e5d1a93d7a (diff)
Add qt_configure_file_v2 function
The function does the same as the original one but respects semicolons in CONTENT argument due to the use of the cmake_parse_arguments variant with PARSE_ARGV. Change-Id: I263662dc18e411a735b586995b82791fc6b888ea Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtCMakeHelpers.cmake43
1 files changed, 31 insertions, 12 deletions
diff --git a/cmake/QtCMakeHelpers.cmake b/cmake/QtCMakeHelpers.cmake
index 53b6deed2a..b6f8d55e1a 100644
--- a/cmake/QtCMakeHelpers.cmake
+++ b/cmake/QtCMakeHelpers.cmake
@@ -1,22 +1,19 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# qt_configure_file(OUTPUT output-file <INPUT input-file | CONTENT content>)
-# input-file is relative to ${CMAKE_CURRENT_SOURCE_DIR}
-# output-file is relative to ${CMAKE_CURRENT_BINARY_DIR}
-#
-# This function is similar to file(GENERATE OUTPUT) except it writes the content
-# to the file at configure time, rather than at generate time. Once CMake 3.18 is released, it can
-# use file(CONFIGURE) in its implementation. Until then, it uses configure_file() with a generic
-# input file as source, when used with the CONTENT signature.
-function(qt_configure_file)
- qt_parse_all_arguments(arg "qt_configure_file" "" "OUTPUT;INPUT;CONTENT" "" ${ARGN})
-
+# The common implementation of qt_configure_file functionality.
+macro(qt_configure_file_impl)
if(NOT arg_OUTPUT)
message(FATAL_ERROR "No output file provided to qt_configure_file.")
endif()
- if(arg_CONTENT)
+ # We use this check for the cases when the specified CONTENT is empty. The value of arg_CONTENT
+ # is undefined, but we still want to create a file with empty content.
+ if(NOT "CONTENT" IN_LIST arg_KEYWORDS_MISSING_VALUES)
+ if(arg_INPUT)
+ message(WARNING "Both CONTENT and INPUT are specified. CONTENT will be used to generate"
+ " output")
+ endif()
set(template_name "QtFileConfigure.txt.in")
# When building qtbase, use the source template file.
# Otherwise use the installed file (basically wherever Qt6 package is found).
@@ -34,6 +31,28 @@ function(qt_configure_file)
endif()
configure_file("${input_file}" "${arg_OUTPUT}" @ONLY)
+endmacro()
+
+# qt_configure_file(OUTPUT output-file <INPUT input-file | CONTENT content>)
+# input-file is relative to ${CMAKE_CURRENT_SOURCE_DIR}
+# output-file is relative to ${CMAKE_CURRENT_BINARY_DIR}
+#
+# This function is similar to file(GENERATE OUTPUT) except it writes the content
+# to the file at configure time, rather than at generate time. Once CMake 3.18 is released, it can
+# use file(CONFIGURE) in its implementation. Until then, it uses configure_file() with a generic
+# input file as source, when used with the CONTENT signature.
+function(qt_configure_file)
+ qt_parse_all_arguments(arg "qt_configure_file" "" "OUTPUT;INPUT;CONTENT" "" ${ARGN})
+ qt_configure_file_impl()
+endfunction()
+
+# The fixed version of qt_configure_file that uses the cmake_parse_arguments variant with PARSE_ARGV
+# to handle arguments with semicolons correctly.
+# TODO: This implementation should replace the previous one, but first need to fix all places where
+# the previous imlementation is used.
+function(qt_configure_file_v2)
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "OUTPUT;INPUT;CONTENT" "")
+ qt_configure_file_impl()
endfunction()
# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out