Skip to content

Commit

Permalink
Improvement to NO_UNITY_BUILD_SOURCES, and fix related bugs
Browse files Browse the repository at this point in the history
The source of the problem was in `qt_set_target_info_properties` which
was not able to process the NO_UNITY_BUILD_SOURCES, and therefore
leaking it into the `TARGET_COPYRIGHT`, ie., the last argument. So, I
decided to pass Unity Build arguments before them, and closer to
SOURCES, which is nicer to read, and avoid similar situation. And
I reverted the work around in the amend commit, and passing the
arguments normally.

This happens because we pass an unfiltered ${ARGN} from
qt_internal_add_executable to qt_set_target_info_properties and that the
current change is merely a workaround that ensures they get
circumstantially filtered out, because the NO_UNITY_BUILD_SOURCES option
appears before any of the first TARGET_ props.

Amend cd12c1f

Task-number: QTBUG-99238
Task-number: QTBUG-109394
Pick-to: 6.5
Change-Id: Idb37937cf53e708425402c90f55bda8816e27f29
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
amirmasoudabdol committed Apr 3, 2023
1 parent 4105ff8 commit ed85df8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 32 deletions.
10 changes: 2 additions & 8 deletions cmake/QtExecutableHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,10 @@ function(qt_internal_add_executable name)
set(arg_NO_UNITY_BUILD "")
endif()

if(arg_NO_UNITY_BUILD_SOURCES)
set(arg_NO_UNITY_BUILD_SOURCES "NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}")
else()
set(arg_NO_UNITY_BUILD_SOURCES "")
endif()

qt_internal_extend_target("${name}"
${arg_NO_UNITY_BUILD}
SOURCES ${arg_SOURCES}
NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES ${private_includes}
DEFINES ${arg_DEFINES}
LIBRARIES
Expand All @@ -140,8 +136,6 @@ function(qt_internal_add_executable name)
MOC_OPTIONS ${arg_MOC_OPTIONS}
ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
${arg_NO_UNITY_BUILD_SOURCES}
${arg_NO_UNITY_BUILD}
)
set_target_properties("${name}" PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
Expand Down
12 changes: 4 additions & 8 deletions cmake/QtModuleHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -579,19 +579,17 @@ function(qt_internal_add_module target)
set(arg_NO_UNITY_BUILD "")
endif()

if(arg_NO_UNITY_BUILD_SOURCES)
set(arg_NO_UNITY_BUILD_SOURCES "NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}")
else()
set(arg_NO_UNITY_BUILD_SOURCES "")
endif()

if(NOT arg_EXTERNAL_HEADERS)
set(arg_EXTERNAL_HEADERS "")
endif()

qt_internal_extend_target("${target}"
${arg_NO_UNITY_BUILD}
SOURCES
${arg_SOURCES}
${arg_EXTERNAL_HEADERS}
NO_UNITY_BUILD_SOURCES
${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES
${private_includes}
SYSTEM_INCLUDE_DIRECTORIES
Expand Down Expand Up @@ -620,8 +618,6 @@ function(qt_internal_add_module target)
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
PRECOMPILED_HEADER ${arg_PRECOMPILED_HEADER}
NO_PCH_SOURCES ${arg_NO_PCH_SOURCES}
${arg_NO_UNITY_BUILD_SOURCES}
${arg_NO_UNITY_BUILD}
)

# The public module define is not meant to be used when building the module itself,
Expand Down
11 changes: 3 additions & 8 deletions cmake/QtPluginHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,11 @@ function(qt_internal_add_plugin target)
set(arg_NO_UNITY_BUILD "")
endif()

if(arg_NO_UNITY_BUILD_SOURCES)
set(arg_NO_UNITY_BUILD_SOURCES "NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}")
else()
set(arg_NO_UNITY_BUILD_SOURCES "")
endif()

qt_internal_extend_target("${target}"
${arg_NO_UNITY_BUILD}
SOURCES ${arg_SOURCES}
NO_UNITY_BUILD_SOURCES
${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES
${private_includes}
SYSTEM_INCLUDE_DIRECTORIES
Expand All @@ -366,8 +363,6 @@ function(qt_internal_add_plugin target)
MOC_OPTIONS ${arg_MOC_OPTIONS}
ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
${arg_NO_UNITY_BUILD_SOURCES}
${arg_NO_UNITY_BUILD}
)

qt_internal_add_repo_local_defines("${target}")
Expand Down
10 changes: 2 additions & 8 deletions cmake/QtToolHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,13 @@ function(qt_internal_add_tool target_name)
set(arg_NO_UNITY_BUILD "")
endif()

if(arg_NO_UNITY_BUILD_SOURCES)
set(arg_NO_UNITY_BUILD_SOURCES "NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}")
else()
set(arg_NO_UNITY_BUILD_SOURCES "")
endif()

qt_internal_add_executable("${target_name}"
OUTPUT_DIRECTORY "${output_dir}"
${exceptions}
NO_INSTALL
${arg_NO_UNITY_BUILD}
SOURCES ${arg_SOURCES}
NO_UNITY_BUILD_SOURCES ${arg_NO_UNITY_BUILD_SOURCES}
INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES}
DEFINES
Expand All @@ -130,8 +126,6 @@ function(qt_internal_add_tool target_name)
TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
TARGET_COMPANY "${arg_TARGET_COMPANY}"
TARGET_COPYRIGHT "${arg_TARGET_COPYRIGHT}"
${arg_NO_UNITY_BUILD_SOURCES}
${arg_NO_UNITY_BUILD}
)
qt_internal_add_target_aliases("${target_name}")
_qt_internal_apply_strict_cpp("${target_name}")
Expand Down

0 comments on commit ed85df8

Please sign in to comment.