cmake adding -xc++ flag to custom compiler (Xilinx Vitis)
I'm trying to use cmake to generate a build for Xilinx FPGA HLS (C++) code. This requires using Xilinx's version of the C++ compiler, v++. In my CMakeLists.txt, I have
set(CMAKE_CXX_COMPILER $ENV{XILINX_VITIS}/bin/v++)
unset(CMAKE_CXX_FLAGS)
add_compile_options(<my options list>)
add_library_target(MyKernel.xclbin OBJECT MyKernel.cpp)
When I run cmake, all the make files get generated, but cmake (or CLion?) generates an error at the very end of the cmake run:
Cannot get compiler information:
Compiler exited with error code 2: /opt/Xilinx/Vitis/2019.2/bin/v++ -xc++ <my options list>
All of the compiler flags I had specified in 'add_compile_options()' appear correctly after the -xc++ option. When I copy-paste the command and run it in a terminal, I get
ERROR: [v++ 60-1520] ***Exception: unrecognised option '-xc++'
Who is adding "-xc++" and how can I get rid of it? When I comment out the setting of the CMAKE_CXX_COMPILER so that it defaults to g++ (and comment out the add_compile_options() since those are specific to v++), I don't get any error.
I am able to subsequently make the project and the v++ compiler is invoked correctly without the -xc++ option and everything builds fine. However, the IDE is unable to resolve any include paths or symbol references outside the file so the IDE is basically useless.
If I run cmake from the command line (versus CLion running it), there is no error, but CLion IDE still cannot resolve references.
Is there a way to trick CLion (assuming CLion is causing the issue) to do it's indexing (or whatever it needs to do when it runs the compiler to get info) using gcc instead? I tried intercepting the call to v++ by creating a script by the same name in my path that called gcc instead when -xc++ was present:
#!/bin/bash
# This script in ~/bin/v++
ARGS_ONLY=${@#"$0"}
if [[ "$ARGS_ONLY" == *"-xc++"* ]]; then
g++ -xc++ -g -fpch-preprocess -v -dD -E
else
$XILINX_VITIS/bin/v++ $ARGS_ONLY
fi
But clion still complained with "cannot get compiler info." What's it expecting when it's getting compiler info?
请先登录再写评论。
Hello!
The thing is that our code-insight features depend on various information that we get from the compiler: system includes, standard defines, compiler features, and so on. To get this information we go directly to the compiler. And therefore CLion can work correctly and stably only with supported compilers: clang and gcc/gcc-based in case of Linux.
Feel free to create a feature request about Xilinx's compiler support in our tracker https://youtrack.jetbrains.com/issues/CPP.
Also you can comment or upvote https://youtrack.jetbrains.com/issue/CPP-9615.