summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-10 17:16:22 (GMT)
committerBrad King <brad.king@kitware.com>2021-11-11 12:16:11 (GMT)
commit129e3c65400a96c1f99b0fd6d445f1b9dc38ad51 (patch)
tree602ca13d34bb8746548b3b56ecf2577ac9e050a0 /Source/cmLocalGenerator.h
parentea289314ef473d6bcdc1ca858aac6cdb15ecf56a (diff)
downloadCMake-129e3c65400a96c1f99b0fd6d445f1b9dc38ad51.zip
CMake-129e3c65400a96c1f99b0fd6d445f1b9dc38ad51.tar.gz
CMake-129e3c65400a96c1f99b0fd6d445f1b9dc38ad51.tar.bz2
Unity Build: Fix per-config sources in multi-config generators
Single-config generators already support unity builds with per-config sources because they compute sources using `CMAKE_BUILD_TYPE` as the configuration. Each original source is either included in the unity build source, or not. Teach multi-config generators to compute the list of sources for inclusion in unity builds using all configurations. Previously they only used the empty string as the configuration. Each original source may be included in some configurations, but not others. Use preprocessor conditions to guard their inclusion when necessary. Fixes: #22892
Diffstat (limited to 'Source/cmLocalGenerator.h')
-rw-r--r--Source/cmLocalGenerator.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 4c9714b..726817a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -14,6 +14,8 @@
#include <utility>
#include <vector>
+#include <cm/optional>
+
#include <cm3p/kwiml/int.h>
#include "cmCustomCommandTypes.h"
@@ -664,6 +666,7 @@ private:
struct UnityBatchedSource
{
cmSourceFile* Source = nullptr;
+ std::vector<size_t> Configs;
UnityBatchedSource(cmSourceFile* sf)
: Source(sf)
{
@@ -672,27 +675,32 @@ private:
struct UnitySource
{
std::string Path;
- UnitySource(std::string path)
+ bool PerConfig = false;
+ UnitySource(std::string path, bool perConfig)
: Path(std::move(path))
+ , PerConfig(perConfig)
{
}
};
UnitySource WriteUnitySource(
- cmGeneratorTarget* target,
+ cmGeneratorTarget* target, std::vector<std::string> const& configs,
cmRange<std::vector<UnityBatchedSource>::const_iterator> sources,
cmValue beforeInclude, cmValue afterInclude, std::string filename) const;
void WriteUnitySourceInclude(std::ostream& unity_file,
+ cm::optional<std::string> const& cond,
std::string const& sf_full_path,
cmValue beforeInclude, cmValue afterInclude,
cmValue uniqueIdName) const;
std::vector<UnitySource> AddUnityFilesModeAuto(
cmGeneratorTarget* target, std::string const& lang,
+ std::vector<std::string> const& configs,
std::vector<UnityBatchedSource> const& filtered_sources,
cmValue beforeInclude, cmValue afterInclude,
std::string const& filename_base, size_t batchSize);
std::vector<UnitySource> AddUnityFilesModeGroup(
cmGeneratorTarget* target, std::string const& lang,
+ std::vector<std::string> const& configs,
std::vector<UnityBatchedSource> const& filtered_sources,
cmValue beforeInclude, cmValue afterInclude,
std::string const& filename_base);