python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / qt-6 / patches / cmake.patch
blob1fb2ea26c35dfa6ecf59e75b86eb0db35872690b
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
19 @@ -6,6 +6,7 @@
20 #include <cstring>
21 #include <sstream>
22 #include <utility>
23 +#include <cstdlib>
25 #include <cm/memory>
27 @@ -325,9 +326,23 @@ static void prefixItems(std::string& exportDirs)
28 for (std::string const& e : entries) {
29 exportDirs += sep;
30 sep = ";";
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");
44 + } else {
45 + exportDirs += std::getenv("out");
46 + }
47 + } else {
48 + exportDirs += std::getenv("out");
49 + }
50 + exportDirs += "/";
52 exportDirs += e;
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
58 @@ -5,6 +5,7 @@
59 #include <memory>
60 #include <sstream>
61 #include <utility>
62 +#include <cstdlib>
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);
78 std::string value;
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");
92 + } else {
93 + value = std::getenv("out");
94 + }
95 + } else {
96 + value = std::getenv("out");
97 + }
98 + value += "/";
100 value += dest;
101 value += "/";
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,
107 sep = ";";
108 if (!cmSystemTools::FileIsFullPath(e) &&
109 cmGeneratorExpression::Find(e) != 0) {
110 - result += prefix;
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");
120 + } else {
121 + result += std::getenv("out");
123 + } else {
124 + result += std::getenv("out");
126 + result += "/";
128 result += e;