From 0290b2aaff20f6c3f80b29d382e21e5dd39a08eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Oct 2010 13:56:19 +0200 Subject: mkspecs: Refactor precompiled-header configuration out of gcc-base(-mac) Preparation for introducing Clang-style precompiled-header support. Reviewed-by: Marius Storm-Olsen --- mkspecs/common/g++-mac.conf | 5 +++++ mkspecs/common/g++.conf | 5 +++++ mkspecs/common/gcc-base-mac.conf | 5 ----- mkspecs/common/gcc-base.conf | 5 ----- mkspecs/common/llvm.conf | 5 +++++ mkspecs/macx-llvm/qmake.conf | 5 +++++ 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/mkspecs/common/g++-mac.conf b/mkspecs/common/g++-mac.conf index 1b8ec6e..bcfd9aa 100644 --- a/mkspecs/common/g++-mac.conf +++ b/mkspecs/common/g++-mac.conf @@ -25,3 +25,8 @@ QMAKE_OBJECTIVE_CFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64 QMAKE_OBJECTIVE_CFLAGS_PPC_64 = $$QMAKE_CFLAGS_PPC_64 QMAKE_LFLAGS_X86_64 = $$QMAKE_CFLAGS_X86_64 QMAKE_LFLAGS_PPC_64 = $$QMAKE_CFLAGS_PPC_64 + +QMAKE_OBJCFLAGS_PRECOMPILE = -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE +QMAKE_OBJCXXFLAGS_PRECOMPILE = -x objective-c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE diff --git a/mkspecs/common/g++.conf b/mkspecs/common/g++.conf index cb82180..d73b38f 100644 --- a/mkspecs/common/g++.conf +++ b/mkspecs/common/g++.conf @@ -16,3 +16,8 @@ QMAKE_LINK_C = $$QMAKE_CC QMAKE_LINK_C_SHLIB = $$QMAKE_CC QMAKE_PCH_OUTPUT_EXT = .gch + +QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE} +QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE diff --git a/mkspecs/common/gcc-base-mac.conf b/mkspecs/common/gcc-base-mac.conf index b65cc5e..5c9a8a1 100644 --- a/mkspecs/common/gcc-base-mac.conf +++ b/mkspecs/common/gcc-base-mac.conf @@ -41,8 +41,3 @@ QMAKE_LFLAGS_INCREMENTAL += -undefined suppress -flat_namespace QMAKE_LFLAGS_SONAME += -install_name$${LITERAL_WHITESPACE} QMAKE_LFLAGS_VERSION += -current_version$${LITERAL_WHITESPACE} QMAKE_LFLAGS_COMPAT_VERSION += -compatibility_version$${LITERAL_WHITESPACE} - -QMAKE_OBJCFLAGS_PRECOMPILE += -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} -QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -QMAKE_OBJCXXFLAGS_PRECOMPILE += -x objective-c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} -QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 2afe9d6..41280c6 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -44,8 +44,6 @@ QMAKE_CFLAGS_SHLIB += -fPIC QMAKE_CFLAGS_STATIC_LIB += -fPIC QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden -QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} -QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE} isEmpty(QMAKE_CXX): QMAKE_CXX = g++ @@ -59,9 +57,6 @@ QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden -QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} - -QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE QMAKE_LINK = $$QMAKE_CXX QMAKE_LINK_SHLIB = $$QMAKE_CXX diff --git a/mkspecs/common/llvm.conf b/mkspecs/common/llvm.conf index 4e54703..3d66357 100644 --- a/mkspecs/common/llvm.conf +++ b/mkspecs/common/llvm.conf @@ -6,3 +6,8 @@ QMAKE_CC = llvm-gcc QMAKE_CXX = llvm-g++ QMAKE_PCH_OUTPUT_EXT = .gch + +QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE} +QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE \ No newline at end of file diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf index 0064fb0..95c2b28 100644 --- a/mkspecs/macx-llvm/qmake.conf +++ b/mkspecs/macx-llvm/qmake.conf @@ -17,4 +17,9 @@ include(../common/mac.conf) include(../common/llvm.conf) include(../common/gcc-base-mac.conf) +QMAKE_OBJCFLAGS_PRECOMPILE = -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE +QMAKE_OBJCXXFLAGS_PRECOMPILE = -x objective-c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + load(qt_config) -- cgit v0.12 From be5a6dd0907f2ea635327ea21a01ebea9b894c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Oct 2010 14:20:56 +0200 Subject: 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 --- qmake/generators/unix/unixmake.cpp | 45 +++++++++++++++++++++++++++++++------ 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); -- cgit v0.12