summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorThomas Bernard <tbernard@go-engineering.de>2020-04-04 09:59:22 (GMT)
committerThomas Bernard <tbernard@go-engineering.de>2020-04-06 19:19:12 (GMT)
commit35a29ec82790890df4872e60943e9127e4603e54 (patch)
tree75f3ae21b74ba3d983a9ae1ed27f6cbd31a53025 /Source/cmcmd.cxx
parent42cefc6bc174f0e6ec87f105b6bf0ca3d53eb2ee (diff)
downloadCMake-35a29ec82790890df4872e60943e9127e4603e54.zip
CMake-35a29ec82790890df4872e60943e9127e4603e54.tar.gz
CMake-35a29ec82790890df4872e60943e9127e4603e54.tar.bz2
llvm-rc: Restore include path for data after explicit preprocessing
Since commit 1c2d031cbd (Add -E cmake_llvm_rc to preprocess files for llvm-rc, 2020-01-14, v3.17.0-rc1~24^2) with llvm-rc we explicitly preprocess RC source files and then compile separately without -I flags. This broke cases where the RC source references data files adjacent to itself or in the include path. This change adds the expansion of the include paths when calling the llvm-rc in order for the resource files to be picked up correctly by llvm-rc. Since the RC compiled file is first preprocessed, the file being compiled by llvm-rc resides in the build directory. In order for llvm-rc to find the resource data specified relative to the .rc file being compiled, the source file path is preppended in the include list so that the original source path takes priority over all the other includes paths specified. A space was added in the CMAKE_INCLUDE_FLAG_RC to make the include directive work properly for llvm-rc. Checks on the rc.exe showed that the syntax change doesn't affect it's proper operation. Fixes: #20529
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx20
1 files changed, 15 insertions, 5 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 2bccbc7..2b8ea24 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1713,23 +1713,33 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args)
// The arguments are
// args[0] == <cmake-executable>
// args[1] == cmake_llvm_rc
- // args[2] == intermediate_file
- // args[3..n] == preprocess+args
+ // args[2] == source_file_path
+ // args[3] == intermediate_file
+ // args[4..n] == preprocess+args
// args[n+1] == --
// args[n+2...] == llvm-rc+args
if (args.size() < 3) {
std::cerr << "Invalid cmake_llvm_rc arguments";
return 1;
}
- const std::string& intermediate_file = args[2];
+ const std::string& intermediate_file = args[3];
+ const std::string& source_file = args[2];
std::vector<std::string> preprocess;
std::vector<std::string> resource_compile;
std::vector<std::string>* pArgTgt = &preprocess;
- for (std::string const& arg : cmMakeRange(args).advance(3)) {
+ for (std::string const& arg : cmMakeRange(args).advance(4)) {
if (arg == "--") {
pArgTgt = &resource_compile;
} else {
- pArgTgt->push_back(arg);
+ if (arg.find("SOURCE_DIR") != std::string::npos) {
+ std::string sourceDirArg = arg;
+ cmSystemTools::ReplaceString(
+ sourceDirArg, "SOURCE_DIR",
+ cmSystemTools::GetFilenamePath(source_file));
+ pArgTgt->push_back(sourceDirArg);
+ } else {
+ pArgTgt->push_back(arg);
+ }
}
}
if (preprocess.empty()) {