[cmake-developers] Incorrect path handling in generation of export files

Dan Liew dan at su-root.co.uk
Mon Jun 22 17:00:30 EDT 2015


Hi,

There is a bug in CMake's export file generator where it does not
correctly escape Windows paths when generating export files . This was
originally reported on the LLVM mailing list [1]. I'm using CMake
3.2.3.

In a generated export file I see

```
# Create imported target LLVMDebugInfoPDB
add_library(LLVMDebugInfoPDB STATIC IMPORTED)

set_target_properties(LLVMDebugInfoPDB PROPERTIES
  INTERFACE_LINK_LIBRARIES "LLVMObject;LLVMSupport;C:\Program Files
(x86)\Microsoft Visual Studio 14.0\DIA SDK\lib\diaguids.lib"
)
```

One of the libraries listed in the INTERFACE_LINK_LIBRARIES has
invalid syntax because the slashes have not been escaped. I believe
the correct solution would be to have CMake convert all paths to CMake
style paths before writing them to export files.


Brad King (CC'ed) had this comment

```
However, CMake should also be taught to escape the backslashes correctly
when generating the export files.  Take a look at

 Source/cmExportFileGenerator.cxx
 Source/cmExportBuildFileGenerator.cxx
 Source/cmExportInstallFileGenerator.cxx

in the CMake source tree.  There are several places that just generate
double quotes around a raw value that should instead use EscapeForCMake.
```

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/086958.html

Thanks,
Dan


More information about the cmake-developers mailing list