Description
On Windows, when the source directory and the build directory are located on different drives (for example, source on C: and build on D:), the generated header file contains an empty include/file content instead of the expected relative path.
This issue occurs because relative path generation fails across different drive letters on Windows.
Steps to Reproduce
- Place the project source directory on drive
C:.
- Configure the build directory on drive
D:.
- Generate the project.
- Inspect the generated header file.
Expected Behavior
The generated header should correctly reference the intended file regardless of whether the source and build directories are on different drives.
Actual Behavior
The generated header contains an empty file/include when the source and build directories are on different drives.
Fix
Subject: [PATCH] fix
---
Index: src/corecmd/main.cpp
<+>UTF-8
===================================================================
diff --git a/src/corecmd/main.cpp b/src/corecmd/main.cpp
--- a/src/corecmd/main.cpp (revision 4a3ff82d89d3101a77ba8dda52868a930cff5a3d)
+++ b/src/corecmd/main.cpp (date 1783647373833)
@@ -787,7 +787,8 @@
fs::copy(path, targetPath, fs::copy_options::overwrite_existing);
} else {
// Make relative reference
- std::string rel = tstr2str(fs::relative(path, targetDir));
+ auto relPath = fs::relative(path, targetDir);
+ std::string rel = tstr2str(relPath.empty() ? path : relPath);
#ifdef _WIN32
// Replace separator
Description
On Windows, when the source directory and the build directory are located on different drives (for example, source on
C:and build onD:), the generated header file contains an empty include/file content instead of the expected relative path.This issue occurs because relative path generation fails across different drive letters on Windows.
Steps to Reproduce
C:.D:.Expected Behavior
The generated header should correctly reference the intended file regardless of whether the source and build directories are on different drives.
Actual Behavior
The generated header contains an empty file/include when the source and build directories are on different drives.
Fix