Commit 408a3a7d authored by Brad King's avatar Brad King
Browse files

Merge branch 'objc-pch' into release-3.16

Merge-request: !3983
parents 602189bb e331367a
...@@ -13,6 +13,8 @@ include(Internal/CMakeCheckCompilerFlag) ...@@ -13,6 +13,8 @@ include(Internal/CMakeCheckCompilerFlag)
set(__pch_header_C "c-header") set(__pch_header_C "c-header")
set(__pch_header_CXX "c++-header") set(__pch_header_CXX "c++-header")
set(__pch_header_OBJC "objective-c-header")
set(__pch_header_OBJCXX "objective-c++-header")
macro(__compiler_gnu lang) macro(__compiler_gnu lang)
# Feature flags. # Feature flags.
......
...@@ -8,9 +8,6 @@ if(__WINDOWS_CLANG) ...@@ -8,9 +8,6 @@ if(__WINDOWS_CLANG)
endif() endif()
set(__WINDOWS_CLANG 1) set(__WINDOWS_CLANG 1)
set(__pch_header_C "c-header")
set(__pch_header_CXX "c++-header")
macro(__windows_compiler_clang_gnu lang) macro(__windows_compiler_clang_gnu lang)
set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l") set(CMAKE_LINK_LIBRARY_FLAG "-l")
......
...@@ -3334,9 +3334,11 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders( ...@@ -3334,9 +3334,11 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
std::string cmGeneratorTarget::GetPchHeader(const std::string& config, std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
const std::string& language) const const std::string& language) const
{ {
if (language != "C" && language != "CXX") { if (language != "C" && language != "CXX" && language != "OBJC" &&
language != "OBJCXX") {
return std::string(); return std::string();
} }
if (this->GetPropertyAsBool("DISABLE_PRECOMPILE_HEADERS")) { if (this->GetPropertyAsBool("DISABLE_PRECOMPILE_HEADERS")) {
return std::string(); return std::string();
} }
...@@ -3367,8 +3369,15 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, ...@@ -3367,8 +3369,15 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
filename = generatorTarget->ObjectDirectory; filename = generatorTarget->ObjectDirectory;
} }
const std::map<std::string, std::string> languageToExtension = {
{ "C", ".h" },
{ "CXX", ".hxx" },
{ "OBJC", ".objc.h" },
{ "OBJCXX", ".objcxx.hxx" }
};
filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(), filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(),
".dir/cmake_pch", ((language == "C") ? ".h" : ".hxx")); ".dir/cmake_pch", languageToExtension.at(language));
const std::string filename_tmp = cmStrCat(filename, ".tmp"); const std::string filename_tmp = cmStrCat(filename, ".tmp");
if (!pchReuseFrom) { if (!pchReuseFrom) {
...@@ -3418,7 +3427,8 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, ...@@ -3418,7 +3427,8 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
std::string cmGeneratorTarget::GetPchSource(const std::string& config, std::string cmGeneratorTarget::GetPchSource(const std::string& config,
const std::string& language) const const std::string& language) const
{ {
if (language != "C" && language != "CXX") { if (language != "C" && language != "CXX" && language != "OBJC" &&
language != "OBJCXX") {
return std::string(); return std::string();
} }
const auto inserted = const auto inserted =
...@@ -3444,9 +3454,20 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, ...@@ -3444,9 +3454,20 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
// For GCC the source extension will be tranformed into .h[xx].gch // For GCC the source extension will be tranformed into .h[xx].gch
if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) { if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) {
filename += ((language == "C") ? ".h.c" : ".hxx.cxx"); const std::map<std::string, std::string> languageToExtension = {
{ "C", ".h.c" },
{ "CXX", ".hxx.cxx" },
{ "OBJC", ".objc.h.m" },
{ "OBJCXX", ".objcxx.hxx.mm" }
};
filename += languageToExtension.at(language);
} else { } else {
filename += ((language == "C") ? ".c" : ".cxx"); const std::map<std::string, std::string> languageToExtension = {
{ "C", ".c" }, { "CXX", ".cxx" }, { "OBJC", ".m" }, { "OBJCXX", ".mm" }
};
filename += languageToExtension.at(language);
} }
const std::string filename_tmp = cmStrCat(filename, ".tmp"); const std::string filename_tmp = cmStrCat(filename, ".tmp");
...@@ -3464,7 +3485,8 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, ...@@ -3464,7 +3485,8 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
std::string cmGeneratorTarget::GetPchFileObject(const std::string& config, std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
const std::string& language) const std::string& language)
{ {
if (language != "C" && language != "CXX") { if (language != "C" && language != "CXX" && language != "OBJC" &&
language != "OBJCXX") {
return std::string(); return std::string();
} }
const auto inserted = const auto inserted =
......
...@@ -2266,7 +2266,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) ...@@ -2266,7 +2266,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources, buildType); target->GetSourceFiles(sources, buildType);
for (const std::string& lang : { "C", "CXX" }) { for (const std::string& lang : { "C", "CXX", "OBJC", "OBJCXX" }) {
auto langSources = auto langSources =
std::count_if(sources.begin(), sources.end(), [lang](cmSourceFile* sf) { std::count_if(sources.begin(), sources.end(), [lang](cmSourceFile* sf) {
return lang == sf->GetLanguage() && return lang == sf->GetLanguage() &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment