diff options
author | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2010-10-18 12:20:56 (GMT) |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2010-10-18 15:43:55 (GMT) |
commit | be5a6dd0907f2ea635327ea21a01ebea9b894c6b (patch) | |
tree | 44831b37824a7223013c19f060beb4b3523ed406 /qmake | |
parent | 0290b2aaff20f6c3f80b29d382e21e5dd39a08eb (diff) | |
download | Qt-be5a6dd0907f2ea635327ea21a01ebea9b894c6b.zip Qt-be5a6dd0907f2ea635327ea21a01ebea9b894c6b.tar.gz Qt-be5a6dd0907f2ea635327ea21a01ebea9b894c6b.tar.bz2 |
qmake: Add support for Clang-style precompiled headers
The config option clang_pch_style will ensure that QMAKE_PCH_OUTPUT_BASE
will not have QMAKE_PCH_OUTPUT_EXT appended, but instead the final output
file QMAKE_PCH_OUTPUT will have the QMAKE_PCH_OUTPUT_EXT included.
Without clang_pch_style:
QMAKE_PCH_OUTPUT_BASE = .pch/debug-shared/QtCore.gch
QMAKE_PCH_OUTPUT = .pch/debug-shared/QtCore.gch/c++
With clang_pch_style:
QMAKE_PCH_OUTPUT_BASE = .pch/debug-shared/QtCore
QMAKE_PCH_OUTPUT = .pch/debug-shared/QtCore/c++.gch
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 45 | ||||
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 28 |
2 files changed, 56 insertions, 17 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 71a6061..43543a1 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -206,6 +206,33 @@ UnixMakefileGenerator::init() // icc style pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")); + } else { + // gcc style (including clang_pch_style) + QString headerPrefix = project->first("QMAKE_PRECOMP_PREFIX"); + QString headerSuffix; + if (project->isActiveConfig("clang_pch_style")) + headerSuffix = project->first("QMAKE_PCH_OUTPUT_EXT"); + else + pchBaseName += project->first("QMAKE_PCH_OUTPUT_EXT"); + + pchBaseName += Option::dir_sep; + QString pchOutputFile; + + if(comps[i] == "C") { + pchOutputFile = "c"; + } else if(comps[i] == "CXX") { + pchOutputFile = "c++"; + } else if(project->isActiveConfig("objective_c")) { + if(comps[i] == "OBJC") + pchOutputFile = "objective-c"; + else if(comps[i] == "OBJCXX") + pchOutputFile = "objective-c++"; + } + + if(!pchOutputFile.isEmpty()) { + pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}", + pchBaseName + pchOutputFile + headerSuffix); + } } if (!pchFlags.isEmpty()) @@ -379,7 +406,9 @@ QStringList QString header_prefix; if(!project->isEmpty("PRECOMPILED_DIR")) header_prefix = project->first("PRECOMPILED_DIR"); - header_prefix += project->first("QMAKE_ORIG_TARGET") + project->first("QMAKE_PCH_OUTPUT_EXT"); + header_prefix += project->first("QMAKE_ORIG_TARGET"); + if (!project->isActiveConfig("clang_pch_style")) + header_prefix += project->first("QMAKE_PCH_OUTPUT_EXT"); if (project->isActiveConfig("icc_pch_style")) { // icc style for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) { @@ -389,23 +418,25 @@ QStringList } } } else { - // gcc style + // gcc style (including clang_pch_style) + QString header_suffix = project->isActiveConfig("clang_pch_style") + ? project->first("QMAKE_PCH_OUTPUT_EXT") : ""; header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX"); for(QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { if(file.endsWith(*it)) { if(!project->isEmpty("QMAKE_CFLAGS_PRECOMPILE")) { - QString precomp_c_h = header_prefix + "c"; + QString precomp_c_h = header_prefix + "c" + header_suffix; if(!ret.contains(precomp_c_h)) ret += precomp_c_h; } if(project->isActiveConfig("objective_c")) { if(!project->isEmpty("QMAKE_OBJCFLAGS_PRECOMPILE")) { - QString precomp_objc_h = header_prefix + "objective-c"; + QString precomp_objc_h = header_prefix + "objective-c" + header_suffix; if(!ret.contains(precomp_objc_h)) ret += precomp_objc_h; } if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) { - QString precomp_objcpp_h = header_prefix + "objective-c++"; + QString precomp_objcpp_h = header_prefix + "objective-c++" + header_suffix; if(!ret.contains(precomp_objcpp_h)) ret += precomp_objcpp_h; } @@ -416,13 +447,13 @@ QStringList for(QStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) { if(file.endsWith(*it)) { if(!project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE")) { - QString precomp_cpp_h = header_prefix + "c++"; + QString precomp_cpp_h = header_prefix + "c++" + header_suffix; if(!ret.contains(precomp_cpp_h)) ret += precomp_cpp_h; } if(project->isActiveConfig("objective_c")) { if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) { - QString precomp_objcpp_h = header_prefix + "objective-c++"; + QString precomp_objcpp_h = header_prefix + "objective-c++" + header_suffix; if(!ret.contains(precomp_objcpp_h)) ret += precomp_objcpp_h; } diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index d16cd6b..7c68316 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -835,7 +835,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(!project->isEmpty("PRECOMPILED_DIR")) precomph_out_dir = project->first("PRECOMPILED_DIR"); - precomph_out_dir += project->first("QMAKE_ORIG_TARGET") + project->first("QMAKE_PCH_OUTPUT_EXT"); + precomph_out_dir += project->first("QMAKE_ORIG_TARGET"); + if (!project->isActiveConfig("clang_pch_style")) + precomph_out_dir += project->first("QMAKE_PCH_OUTPUT_EXT"); if (project->isActiveConfig("icc_pch_style")) { // icc style @@ -849,19 +851,22 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) precomp_files << precomph_out_dir << sourceFile << objectFile; } else { - // gcc style + // gcc style (including clang_pch_style) precomph_out_dir += Option::dir_sep; QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX"); + QString header_suffix = project->isActiveConfig("clang_pch_style") + ? project->first("QMAKE_PCH_OUTPUT_EXT") : ""; + if(!project->isEmpty("QMAKE_CFLAGS_PRECOMPILE")) - precomp_files += precomph_out_dir + header_prefix + "c"; + precomp_files += precomph_out_dir + header_prefix + "c" + header_suffix; if(!project->isEmpty("QMAKE_CXXFLAGS_PRECOMPILE")) - precomp_files += precomph_out_dir + header_prefix + "c++"; + precomp_files += precomph_out_dir + header_prefix + "c++" + header_suffix; if(project->isActiveConfig("objective_c")) { if(!project->isEmpty("QMAKE_OBJCFLAGS_PRECOMPILE")) - precomp_files += precomph_out_dir + header_prefix + "objective-c"; + precomp_files += precomph_out_dir + header_prefix + "objective-c" + header_suffix; if(!project->isEmpty("QMAKE_OBJCXXFLAGS_PRECOMPILE")) - precomp_files += precomph_out_dir + header_prefix + "objective-c++"; + precomp_files += precomph_out_dir + header_prefix + "objective-c++" + header_suffix; } } t << "-$(DEL_FILE) " << precomp_files.join(" ") << "\n\t"; @@ -930,7 +935,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QString pchOutput; if(!project->isEmpty("PRECOMPILED_DIR")) pchOutput = project->first("PRECOMPILED_DIR"); - pchOutput += pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT"); + pchOutput += pchBaseName; + if (!project->isActiveConfig("clang_pch_style")) + pchOutput += project->first("QMAKE_PCH_OUTPUT_EXT"); if (project->isActiveConfig("icc_pch_style")) { // icc style @@ -943,9 +950,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) pchFlags = pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile) .replace("${QMAKE_PCH_TEMP_OBJECT}", objectFile); } else { - // gcc style + // gcc style (including clang_pch_style) QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX"); - + QString header_suffix = project->isActiveConfig("clang_pch_style") + ? project->first("QMAKE_PCH_OUTPUT_EXT") : ""; pchOutput += Option::dir_sep; QString pchOutputDir = pchOutput, pchOutputFile; @@ -961,7 +969,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(pchOutputFile.isEmpty()) continue; - pchOutput += header_prefix + pchOutputFile; + pchOutput += header_prefix + pchOutputFile + header_suffix; t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t") << "\n\t" << mkdir_p_asstring(pchOutputDir); |