summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/get_cmake_property.rst6
-rw-r--r--Help/command/get_source_file_property.rst14
-rw-r--r--Help/command/get_target_property.rst16
-rw-r--r--Help/command/get_test_property.rst14
-rw-r--r--Help/command/set_directory_properties.rst5
-rw-r--r--Help/command/set_target_properties.rst6
-rw-r--r--Help/command/set_tests_properties.rst5
-rw-r--r--Help/manual/cmake-cxxmodules.7.rst4
-rw-r--r--Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst4
-rw-r--r--Help/prop_tgt/UNITY_BUILD.rst5
-rw-r--r--Modules/CheckLanguage.cmake28
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmComputeLinkInformation.h2
-rw-r--r--Source/cmFindLibraryCommand.cxx8
-rw-r--r--Source/cmGlobalGenerator.cxx30
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Source/cmLocalGenerator.cxx9
-rw-r--r--Source/cmMakefileTargetGenerator.cxx7
-rw-r--r--Tests/CMakeOnly/CMakeLists.txt7
-rw-r--r--Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt17
-rw-r--r--Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt14
-rw-r--r--Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake11
-rw-r--r--Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt26
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx10
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/main.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/unity.h7
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx8
-rw-r--r--Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx10
31 files changed, 248 insertions, 48 deletions
diff --git a/Help/command/get_cmake_property.rst b/Help/command/get_cmake_property.rst
index b1d18a0..9f78a86 100644
--- a/Help/command/get_cmake_property.rst
+++ b/Help/command/get_cmake_property.rst
@@ -5,11 +5,11 @@ Get a global property of the CMake instance.
.. code-block:: cmake
- get_cmake_property(<var> <property>)
+ get_cmake_property(<variable> <property>)
Gets a global property from the CMake instance. The value of
-the ``<property>`` is stored in the variable ``<var>``.
-If the property is not found, ``<var>`` will be set to ``NOTFOUND``.
+the ``<property>`` is stored in the specified ``<variable>``.
+If the property is not found, ``<variable>`` will be set to ``NOTFOUND``.
See the :manual:`cmake-properties(7)` manual for available properties.
In addition to global properties, this command (for historical reasons)
diff --git a/Help/command/get_source_file_property.rst b/Help/command/get_source_file_property.rst
index e83e9c2..a7e5191 100644
--- a/Help/command/get_source_file_property.rst
+++ b/Help/command/get_source_file_property.rst
@@ -9,14 +9,12 @@ Get a property for a source file.
[DIRECTORY <dir> | TARGET_DIRECTORY <target>]
<property>)
-Gets a property from a source file. The value of the property is
-stored in the specified ``<variable>``. If the source property is not found,
-the behavior depends on whether it has been defined to be an ``INHERITED``
-property or not (see :command:`define_property`). Non-inherited properties
-will set ``variable`` to ``NOTFOUND``, whereas inherited properties will search
-the relevant parent scope as described for the :command:`define_property`
-command and if still unable to find the property, ``variable`` will be set to
-an empty string.
+Gets a property from a source file. The value of the property is stored in
+the specified ``<variable>``. If the ``<file>`` is not a source file, or the
+source property is not found, ``<variable>`` will be set to ``NOTFOUND``.
+If the source property was defined to be an ``INHERITED`` property (see
+:command:`define_property`), the search will include the relevant parent
+scopes, as described for the :command:`define_property` command.
By default, the source file's property will be read from the current source
directory's scope.
diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst
index 8c6dcb1..1554a85 100644
--- a/Help/command/get_target_property.rst
+++ b/Help/command/get_target_property.rst
@@ -5,16 +5,14 @@ Get a property from a target.
.. code-block:: cmake
- get_target_property(<VAR> target property)
+ get_target_property(<variable> <target> <property>)
-Get a property from a target. The value of the property is stored in
-the variable ``<VAR>``. If the target property is not found, the behavior
-depends on whether it has been defined to be an ``INHERITED`` property
-or not (see :command:`define_property`). Non-inherited properties will
-set ``<VAR>`` to ``<VAR>-NOTFOUND``, whereas inherited properties will search
-the relevant parent scope as described for the :command:`define_property`
-command and if still unable to find the property, ``<VAR>`` will be set to
-an empty string.
+Get a property from a target. The value of the property is stored in the
+specified ``<variable>``. If the target property is not found, ``<variable>``
+will be set to ``<variable>-NOTFOUND``. If the target property was defined to
+be an ``INHERITED`` property (see :command:`define_property`), the search will
+include the relevant parent scopes, as described for the
+:command:`define_property` command.
Use :command:`set_target_properties` to set target property values.
Properties are usually used to control how a target is built, but some
diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst
index 1fcf24e..3f1a64c 100644
--- a/Help/command/get_test_property.rst
+++ b/Help/command/get_test_property.rst
@@ -5,16 +5,14 @@ Get a property of the test.
.. code-block:: cmake
- get_test_property(test property [DIRECTORY <dir>] VAR)
+ get_test_property(<test> <property> [DIRECTORY <dir>] <variable>)
Get a property from the test. The value of the property is stored in
-the variable ``VAR``. If the test property is not found, the behavior
-depends on whether it has been defined to be an ``INHERITED`` property
-or not (see :command:`define_property`). Non-inherited properties will
-set ``VAR`` to "NOTFOUND", whereas inherited properties will search the
-relevant parent scope as described for the :command:`define_property`
-command and if still unable to find the property, ``VAR`` will be set to
-an empty string.
+the specified ``<variable>``. If the ``<test>`` is not defined, or the
+test property is not found, ``<variable>`` will be set to ``NOTFOUND``.
+If the test property was defined to be an ``INHERITED`` property (see
+:command:`define_property`), the search will include the relevant parent
+scopes, as described for the :command:`define_property` command.
For a list of standard properties you can type
:option:`cmake --help-property-list`.
diff --git a/Help/command/set_directory_properties.rst b/Help/command/set_directory_properties.rst
index 93ad39b..6d94808 100644
--- a/Help/command/set_directory_properties.rst
+++ b/Help/command/set_directory_properties.rst
@@ -5,9 +5,10 @@ Set properties of the current directory and subdirectories.
.. code-block:: cmake
- set_directory_properties(PROPERTIES prop1 value1 [prop2 value2] ...)
+ set_directory_properties(PROPERTIES <prop1> <value1> [<prop2> <value2>] ...)
-Sets properties of the current directory and its subdirectories in key-value pairs.
+Sets properties of the current directory and its subdirectories in key-value
+pairs.
See also the :command:`set_property(DIRECTORY)` command.
diff --git a/Help/command/set_target_properties.rst b/Help/command/set_target_properties.rst
index 874788b..5357575 100644
--- a/Help/command/set_target_properties.rst
+++ b/Help/command/set_target_properties.rst
@@ -5,9 +5,9 @@ Targets can have properties that affect how they are built.
.. code-block:: cmake
- set_target_properties(target1 target2 ...
- PROPERTIES prop1 value1
- prop2 value2 ...)
+ set_target_properties(<targets> ...
+ PROPERTIES <prop1> <value1>
+ [<prop2> <value2>] ...)
Sets properties on targets. The syntax for the command is to list all
the targets you want to change, and then provide the values you want to
diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst
index da750e3..a21f746 100644
--- a/Help/command/set_tests_properties.rst
+++ b/Help/command/set_tests_properties.rst
@@ -5,7 +5,10 @@ Set a property of the tests.
.. code-block:: cmake
- set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)
+ set_tests_properties(<tests>...
+ [DIRECTORY <dir>]
+ PROPERTIES <prop1> <value1>
+ [<prop2> <value2>]...)
Sets a property for the tests. If the test is not found, CMake
will report an error.
diff --git a/Help/manual/cmake-cxxmodules.7.rst b/Help/manual/cmake-cxxmodules.7.rst
index b4c9cf1..3ee6645 100644
--- a/Help/manual/cmake-cxxmodules.7.rst
+++ b/Help/manual/cmake-cxxmodules.7.rst
@@ -30,6 +30,10 @@ following queries. The first query that provides a yes/no answer is used.
- Otherwise, the source file will be scanned if the compiler and generator
support scanning. See policy :policy:`CMP0155`.
+Note that any scanned source will be excluded from any unity build (see
+:prop_tgt:`UNITY_BUILD`) because module-related statements can only happen at
+one place within a C++ translation unit.
+
Compiler Support
================
diff --git a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst
index ae526ac..38a0a78 100644
--- a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst
+++ b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst
@@ -11,3 +11,7 @@ in the same way as it would with unity builds disabled.
This property helps with "ODR (One definition rule)" problems where combining
a particular source file with others might lead to build errors or other
unintended side effects.
+
+Note that sources which are scanned for C++ modules (see
+:manual:`cmake-cxxmodules(7)`) are not eligible for unity build inclusion and
+will automatically be excluded.
diff --git a/Help/prop_tgt/UNITY_BUILD.rst b/Help/prop_tgt/UNITY_BUILD.rst
index f827a20..9d68250 100644
--- a/Help/prop_tgt/UNITY_BUILD.rst
+++ b/Help/prop_tgt/UNITY_BUILD.rst
@@ -64,6 +64,11 @@ a number of measures to help address such problems:
:prop_sf:`INCLUDE_DIRECTORIES` source property will not be combined
into a unity source.
+* Any source file which is scanned for C++ module sources via
+ :prop_tgt:`CXX_SCAN_FOR_MODULES`, :prop_sf:`CXX_SCAN_FOR_MODULES`, or
+ membership of a ``CXX_MODULES`` file set will not be combined into a unity
+ source. See :manual:`cmake-cxxmodules(7)` for details.
+
* Projects can prevent an individual source file from being combined into
a unity source by setting its :prop_sf:`SKIP_UNITY_BUILD_INCLUSION`
source property to true. This can be a more effective way to prevent
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake
index 94948b9..bad3590 100644
--- a/Modules/CheckLanguage.cmake
+++ b/Modules/CheckLanguage.cmake
@@ -41,6 +41,12 @@ or :command:`project` commands:
not be set without also setting
:variable:`CMAKE_<LANG>_COMPILER` to a NVCC compiler.
+ :variable:`CMAKE_<LANG>_PLATFORM <CMAKE_HIP_PLATFORM>`
+ This variable is set to the detected GPU platform when ``<lang>`` is ``HIP``.
+
+ If the variable is already set its value is always preserved. Only compatible values
+ will be considered for :variable:`CMAKE_<LANG>_COMPILER`.
+
For example:
.. code-block:: cmake
@@ -66,15 +72,23 @@ macro(check_language lang)
set(extra_compiler_variables)
if("${lang}" MATCHES "^(CUDA|HIP)$" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")")
+ set(extra_compiler_variables "set(CMAKE_${lang}_HOST_COMPILER \\\"\${CMAKE_${lang}_HOST_COMPILER}\\\")")
+ endif()
+
+ if("${lang}" STREQUAL "HIP")
+ list(APPEND extra_compiler_variables "set(CMAKE_${lang}_PLATFORM \\\"\${CMAKE_${lang}_PLATFORM}\\\")")
endif()
+ list(TRANSFORM extra_compiler_variables PREPEND "\"")
+ list(TRANSFORM extra_compiler_variables APPEND "\\n\"")
+ list(JOIN extra_compiler_variables "\n " extra_compiler_variables)
+
set(_cl_content
"cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(Check${lang} ${lang})
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
- \"${extra_compiler_variables}\\n\"
+ ${extra_compiler_variables}
)"
)
@@ -95,6 +109,11 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
else()
set(_D_CMAKE_TOOLCHAIN_FILE "")
endif()
+ if(CMAKE_${lang}_PLATFORM)
+ set(_D_CMAKE_LANG_PLATFORM "-DCMAKE_${lang}_PLATFORM:STRING=${CMAKE_${lang}_PLATFORM}")
+ else()
+ set(_D_CMAKE_LANG_PLATFORM "")
+ endif()
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}
COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
@@ -103,6 +122,7 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
${_D_CMAKE_GENERATOR_INSTANCE}
${_D_CMAKE_MAKE_PROGRAM}
${_D_CMAKE_TOOLCHAIN_FILE}
+ ${_D_CMAKE_LANG_PLATFORM}
OUTPUT_VARIABLE _cl_output
ERROR_VARIABLE _cl_output
RESULT_VARIABLE _cl_result
@@ -130,6 +150,10 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
mark_as_advanced(CMAKE_${lang}_HOST_COMPILER)
endif()
+ if(CMAKE_${lang}_PLATFORM)
+ set(CMAKE_${lang}_PLATFORM "${CMAKE_${lang}_PLATFORM}" CACHE STRING "${lang} platform")
+ mark_as_advanced(CMAKE_${lang}_PLATFORM)
+ endif()
endif()
endmacro()
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 1b69f6e..e7bef68 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -260,7 +260,7 @@ cmComputeLinkInformation::cmComputeLinkInformation(
, Config(config)
{
// Check whether to recognize OpenBSD-style library versioned names.
- this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ this->IsOpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_OPENBSD_VERSIONING");
// Allocate internals.
@@ -1574,7 +1574,7 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
libext += ')';
// Add an optional OpenBSD-style version or major.minor.version component.
- if (this->OpenBSD || type == LinkShared) {
+ if (this->IsOpenBSD || type == LinkShared) {
libext += "(\\.[0-9]+)*";
}
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 3ee995f..2a06530 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -254,7 +254,7 @@ private:
std::unique_ptr<cmOrderDirectories> OrderRuntimeSearchPath;
bool OldLinkDirMode;
- bool OpenBSD;
+ bool IsOpenBSD;
bool LinkDependsNoShared;
bool RuntimeUseChrpath;
bool NoSONameUsesPath;
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index df77ad0..9df7665 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -207,7 +207,7 @@ struct cmFindLibraryHelper
std::string BestPath;
// Support for OpenBSD shared library naming: lib<name>.so.<major>.<minor>
- bool OpenBSD;
+ bool IsOpenBSD;
bool DebugMode;
@@ -320,7 +320,7 @@ cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf,
this->RegexFromList(this->SuffixRegexStr, this->Suffixes);
// Check whether to use OpenBSD-style library version comparisons.
- this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ this->IsOpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_OPENBSD_VERSIONING");
}
@@ -390,7 +390,7 @@ void cmFindLibraryHelper::AddName(std::string const& name)
std::string regex = cmStrCat('^', this->PrefixRegexStr);
this->RegexFromLiteral(regex, name);
regex += this->SuffixRegexStr;
- if (this->OpenBSD) {
+ if (this->IsOpenBSD) {
regex += "(\\.[0-9]+\\.[0-9]+)?";
}
regex += "$";
@@ -472,7 +472,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
size_type suffix = this->GetSuffixIndex(name.Regex.match(2));
unsigned int major = 0;
unsigned int minor = 0;
- if (this->OpenBSD) {
+ if (this->IsOpenBSD) {
sscanf(name.Regex.match(3).c_str(), ".%u.%u", &major, &minor);
}
if (this->BestPath.empty() || prefix < bestPrefix ||
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index c2b972d..5aaa0b8 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1587,6 +1587,13 @@ bool cmGlobalGenerator::Compute()
}
}
+ // Add unity sources after computing compile features. Unity sources do
+ // not change the set of languages or features, but we need to know them
+ // to filter out sources that are scanned for C++ module dependencies.
+ if (!this->AddUnitySources()) {
+ return false;
+ }
+
for (const auto& localGen : this->LocalGenerators) {
cmMakefile* mf = localGen->GetMakefile();
for (const auto& g : mf->GetInstallGenerators()) {
@@ -1863,7 +1870,6 @@ bool cmGlobalGenerator::AddAutomaticSources()
if (!gt->CanCompileSources()) {
continue;
}
- lg->AddUnityBuild(gt.get());
lg->AddISPCDependencies(gt.get());
// Targets that reuse a PCH are handled below.
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
@@ -1895,6 +1901,28 @@ bool cmGlobalGenerator::AddAutomaticSources()
return true;
}
+bool cmGlobalGenerator::AddUnitySources()
+{
+ for (const auto& lg : this->LocalGenerators) {
+ for (const auto& gt : lg->GetGeneratorTargets()) {
+ if (!gt->CanCompileSources()) {
+ continue;
+ }
+ lg->AddUnityBuild(gt.get());
+ }
+ }
+ // The above transformation may have changed the classification of sources.
+ // Clear the source list and classification cache (KindedSources) of all
+ // targets so that it will be recomputed correctly by the generators later
+ // now that the above transformations are done for all targets.
+ for (const auto& lg : this->LocalGenerators) {
+ for (const auto& gt : lg->GetGeneratorTargets()) {
+ gt->ClearSourcesCache();
+ }
+ }
+ return true;
+}
+
std::unique_ptr<cmLinkLineComputer> cmGlobalGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index aa54f69..763136e 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -677,6 +677,7 @@ protected:
bool AddHeaderSetVerification();
bool AddAutomaticSources();
+ bool AddUnitySources();
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 168cd41..7337ea2 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3134,6 +3134,15 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources, configs[ci]);
for (cmSourceFile* sf : sources) {
+ // Files which need C++ scanning cannot participate in unity builds as
+ // there is a single place in TUs that may perform module-dependency bits
+ // and a unity source cannot `#include` them in-order and represent a
+ // valid TU.
+ if (sf->GetLanguage() == "CXX"_s &&
+ target->NeedDyndepForSource("CXX", configs[ci], sf)) {
+ continue;
+ }
+
auto mi = index.find(sf);
if (mi == index.end()) {
unitySources.emplace_back(sf);
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 74b4b75..90afb1b 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1722,11 +1722,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
if (!ccg.GetCC().GetDepfile().empty()) {
// Add dependency over timestamp file for dependencies management
- auto dependTimestamp = cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator->MaybeRelativeToTopBinDir(
- cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts")));
+ auto dependTimestamp = this->LocalGenerator->MaybeRelativeToTopBinDir(
+ cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts"));
- depends.push_back(dependTimestamp);
+ depends.emplace_back(std::move(dependTimestamp));
}
// Write the rule.
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt
index a41b44e..30cabf1 100644
--- a/Tests/CMakeOnly/CMakeLists.txt
+++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -25,6 +25,13 @@ add_CMakeOnly_test(CheckCXXSymbolExists)
add_CMakeOnly_test(CheckCXXCompilerFlag)
add_CMakeOnly_test(CheckLanguage)
+if (CMake_TEST_HIP)
+ set_property(TEST CMakeOnly.CheckLanguage APPEND PROPERTY LABELS "HIP")
+ add_CMakeOnly_test(CheckLanguageHIPPlatform)
+ set_property(TEST CMakeOnly.CheckLanguageHIPPlatform APPEND PROPERTY LABELS "HIP")
+ add_CMakeOnly_test(CheckLanguageHIPPlatform2)
+ set_property(TEST CMakeOnly.CheckLanguageHIPPlatform2 APPEND PROPERTY LABELS "HIP")
+endif()
add_CMakeOnly_test(CheckStructHasMember)
diff --git a/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt
new file mode 100644
index 0000000..03b8aa0
--- /dev/null
+++ b/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required (VERSION 3.28)
+project(CheckLanguageHIPPlatform NONE)
+include(CheckLanguage)
+
+check_language(HIP)
+
+if(NOT DEFINED CMAKE_HIP_COMPILER)
+ message(FATAL_ERROR "check_language did not set result")
+endif()
+
+if (NOT CMAKE_HIP_COMPILER)
+ message(FATAL_ERROR "check_language should not fail!")
+endif()
+
+if (NOT DEFINED CMAKE_HIP_PLATFORM)
+ message(FATAL_ERROR "check_language did not set CMAKE_HIP_PLATFORM!")
+endif()
diff --git a/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt
new file mode 100644
index 0000000..f251c49
--- /dev/null
+++ b/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required (VERSION 3.28)
+project(CheckLanguageHIPPlatform2 NONE)
+include(CheckLanguage)
+
+set(CMAKE_HIP_PLATFORM "not-a-hip-platform" CACHE STRING "")
+check_language(HIP)
+
+if(NOT DEFINED CMAKE_HIP_COMPILER)
+ message(FATAL_ERROR "check_language did not set result")
+endif()
+
+if (CMAKE_HIP_COMPILER)
+ message(FATAL_ERROR "check_language should have failed")
+endif()
diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake
index 19c09c8..c3725a4 100644
--- a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake
+++ b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake
@@ -24,6 +24,17 @@ add_library(toplib STATIC toplib.c)
add_subdirectory(DepfileSubdir)
+set(TEST_SPACE 1)
+if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+ execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
+ if(NOT res EQUAL 0 OR NOT out MATCHES "GNU")
+ set(TEST_SPACE 0)
+ endif()
+endif()
+if(TEST_SPACE)
+ add_subdirectory(DepfileSubdirWithSpace)
+endif()
+
add_custom_command(
OUTPUT toplib2.c
DEPFILE toplib2.c.d
diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt
new file mode 100644
index 0000000..204f740
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+add_subdirectory("path with space")
diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt
new file mode 100644
index 0000000..37c0a57
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt"
+ COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt"
+ DEPFILE dummy.txt.d
+)
+
+add_custom_target(subdir_space ALL
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt"
+)
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index 514e0f3..abede44 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -172,6 +172,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(simple)
run_cxx_module_test(vs-without-flags)
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
+ run_cxx_module_test(unity-build)
run_cxx_module_test(object-library)
run_cxx_module_test(generated)
run_cxx_module_test(deep-chain)
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt
new file mode 100644
index 0000000..ce1751d
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_unity CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+set(CMAKE_UNITY_BUILD 1)
+
+add_executable(unity)
+target_sources(unity
+ PRIVATE
+ main.cxx
+ unity1.cxx
+ unity2.cxx
+ PRIVATE
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx)
+target_compile_features(unity PUBLIC cxx_std_20)
+
+set_property(SOURCE unity1.cxx unity2.cxx
+ PROPERTY
+ CXX_SCAN_FOR_MODULES 0)
+
+add_test(NAME unity COMMAND unity)
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx
new file mode 100644
index 0000000..148b033
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx
@@ -0,0 +1,10 @@
+module;
+
+#include "unity.h"
+
+export module importable;
+
+export int from_import()
+{
+ return unity1() + unity2();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx
new file mode 100644
index 0000000..feb38d2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx
@@ -0,0 +1,6 @@
+import importable;
+
+int main(int argc, char* argv[])
+{
+ return from_import();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity.h b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h
new file mode 100644
index 0000000..4a65a4b
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h
@@ -0,0 +1,7 @@
+#ifndef unity_h
+#define unity_h
+
+int unity1();
+int unity2();
+
+#endif
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx
new file mode 100644
index 0000000..fd1cbb3
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx
@@ -0,0 +1,8 @@
+#include "unity.h"
+
+#define DETECT_UNITY
+
+int unity1()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx
new file mode 100644
index 0000000..0f25cff
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx
@@ -0,0 +1,10 @@
+#include "unity.h"
+
+#ifndef DETECT_UNITY
+# error "Should have detected a unity build"
+#endif
+
+int unity2()
+{
+ return 0;
+}