1 commit 4f497c358e0386b65df1c1d636aadf72f8647134
2 Author: Nick Cao <nickcao@nichi.co>
3 Date: Tue Apr 19 13:49:59 2022 +0800
5 patch cmake file generation for nixpkgs packaging
7 As of qt 6.3.0, installing components into different prefixes is not
8 supported. To workaround that, we move files to their designated in the
9 postInstall hook. However the generated cmake files still have
10 references to the original prefix, and would cause issues when using
11 said components as the dependency of other packages. The purpose of this
12 patch is to closely match the output layout of qt, and rewrite the
13 generated cmake files to point to the corrected pathes.
15 diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
16 index 8b0f64e23b..03291e2ee2 100644
17 --- a/Source/cmExportFileGenerator.cxx
18 +++ b/Source/cmExportFileGenerator.cxx
27 @@ -325,9 +326,23 @@ static void prefixItems(std::string& exportDirs)
28 for (std::string const& e : entries) {
31 - if (!cmSystemTools::FileIsFullPath(e) &&
32 - e.find("${_IMPORT_PREFIX}") == std::string::npos) {
33 - exportDirs += "${_IMPORT_PREFIX}/";
34 + if (!cmSystemTools::FileIsFullPath(e)) {
35 + if (std::getenv("dev")) {
36 + if (cmHasLiteralPrefix(e, "include") || cmHasLiteralPrefix(e, "./include")) {
37 + exportDirs += std::getenv("dev");
38 + } else if (cmHasLiteralPrefix(e, "bin") || cmHasLiteralPrefix(e, "./bin")) {
39 + exportDirs += std::getenv("dev");
40 + } else if (cmHasLiteralPrefix(e, "mkspecs") || cmHasLiteralPrefix(e, "./mkspecs")) {
41 + exportDirs += std::getenv("dev");
42 + } else if (cmHasLiteralPrefix(e, "libexec") || cmHasLiteralPrefix(e, "./libexec")) {
43 + exportDirs += std::getenv("dev");
45 + exportDirs += std::getenv("out");
48 + exportDirs += std::getenv("out");
54 diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
55 index 4a3c565bce..5afa9e5e50 100644
56 --- a/Source/cmExportInstallFileGenerator.cxx
57 +++ b/Source/cmExportInstallFileGenerator.cxx
64 #include "cmExportSet.h"
65 #include "cmGeneratedFileStream.h"
66 @@ -263,7 +264,7 @@ void cmExportInstallFileGenerator::LoadConfigFiles(std::ostream& os)
68 void cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string& input)
70 - cmGeneratorExpression::ReplaceInstallPrefix(input, "${_IMPORT_PREFIX}");
71 + cmGeneratorExpression::ReplaceInstallPrefix(input, std::getenv("out"));
74 bool cmExportInstallFileGenerator::GenerateImportFileConfig(
75 @@ -381,9 +382,24 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
76 // Construct the installed location of the target.
77 std::string dest = itgen->GetDestination(config);
80 if (!cmSystemTools::FileIsFullPath(dest)) {
81 - // The target is installed relative to the installation prefix.
82 - value = "${_IMPORT_PREFIX}/";
83 + if (std::getenv("dev")) {
84 + if (cmHasLiteralPrefix(dest, "include") || cmHasLiteralPrefix(dest, "./include")) {
85 + value = std::getenv("dev");
86 + } else if (cmHasLiteralPrefix(dest, "bin") || cmHasLiteralPrefix(dest, "./bin")) {
87 + value = std::getenv("dev");
88 + } else if (cmHasLiteralPrefix(dest, "mkspecs") || cmHasLiteralPrefix(dest, "./mkspecs")) {
89 + value = std::getenv("dev");
90 + } else if (cmHasLiteralPrefix(dest, "libexec") || cmHasLiteralPrefix(dest, "./libexec")) {
91 + value = std::getenv("dev");
93 + value = std::getenv("out");
96 + value = std::getenv("out");
102 diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
103 index 840f5112d6..7bb4ab41aa 100644
104 --- a/Source/cmGeneratorExpression.cxx
105 +++ b/Source/cmGeneratorExpression.cxx
106 @@ -197,7 +197,22 @@ static void prefixItems(const std::string& content, std::string& result,
108 if (!cmSystemTools::FileIsFullPath(e) &&
109 cmGeneratorExpression::Find(e) != 0) {
111 + if (std::getenv("dev")) {
112 + if (cmHasLiteralPrefix(e, "include") || cmHasLiteralPrefix(e, "./include")) {
113 + result += std::getenv("dev");
114 + } else if (cmHasLiteralPrefix(e, "bin") || cmHasLiteralPrefix(e, "./bin")) {
115 + result += std::getenv("dev");
116 + } else if (cmHasLiteralPrefix(e, "mkspecs") || cmHasLiteralPrefix(e, "./mkspecs")) {
117 + result += std::getenv("dev");
118 + } else if (cmHasLiteralPrefix(e, "libexec") || cmHasLiteralPrefix(e, "./libexec")) {
119 + result += std::getenv("dev");
121 + result += std::getenv("out");
124 + result += std::getenv("out");