[LLVMdev] [CMake] Generated LLVMConfig.cmake and LLVMExports.cmake broken under Visual Studio 2015
Dan Liew
dan at su-root.co.uk
Thu Jun 18 13:39:00 PDT 2015
Hi,
Myself and a colleague of mine are trying to use LLVM's exported
targets [1] on trunk and I've noticed that the generated CMake files
(LLVMConfig.cmake and LLVMExport.cmake) are broken when trying to use
Visual Studio 2015 (using CMake 3.2.1).
## Broken target properties in LLVMExports.cmake
LLVM itself builds fine but when our project tries to do
``find_package(LLVM)`` we get the following error message (see [2] for
context).
```
-- Looking for LLVM
CMake Warning (dev) at
C:/Users/me/Documents/halide/llvm-build/share/llvm/cmake/LLVMExports.cmake:232
(set_target_properties):
Syntax error in cmake code at
C:/Users/me/Documents/halide/llvm-build/share/llvm/cmake/LLVMExports.cmake:233
when parsing string
LLVMObject;LLVMSupport;C:\Program Files (x86)\Microsoft Visual
Studio 14.0\DIA SDK\lib\diaguids.lib
Invalid escape sequence \P
Policy CMP0010 is not set: Bad variable reference syntax is an error. Run
"cmake --help-policy CMP0010" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
Call Stack (most recent call first):
c:/Users/me/Documents/halide/llvm-build/share/llvm/cmake/LLVMConfig.cmake:174
(include)
CMakeLists.txt:14 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
```
The issue is the that that generated LLVMExports.cmake file has this in it
```
# 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"
)
```
The problem is that the path to diaguids.lib is a windows path and not
a CMake style path so the backslashes get interpreted as escape
sequences.
I think this is a bug in CMake.
@Brad: Do you agree?
## Broken paths in LLVMConfig.cmake
This is a minor issue but I'm not sure if this a bug or an artifact of
using Visual Studio but some of the paths specified in
LLVMConfig.cmake are not real paths because they contain
``$(Configuration)``.
```
set(LLVM_BUILD_LIBRARY_DIR
"C:/Users/alexander.APRELEV/Documents/halide/llvm-build/$(Configuration)/lib")
...
set(LLVM_TOOLS_BINARY_DIR
"C:/Users/alexander.APRELEV/Documents/halide/llvm-build/$(Configuration)/bin")
```
The problem is that I was trying to check if
${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}
exists at configure time (which works on OSX and Linux) but this fails
when using Visual Studio because ``$(Configuration)`` is in the path.
Is this intentional?
[1] http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
[2] https://github.com/halide/Halide/pull/825
Thanks,
Dan.
More information about the llvm-dev
mailing list