[CMake] [cmake-developers] Obtaining header file dependencies of a source file manually
Dan Liew
dan at su-root.co.uk
Tue Dec 1 14:53:25 EST 2015
> I fail to see why that should not work. Producing LLVM bitcode from
> C++ with Clang is just adding -emit-llvm flag, right? So, why can't
> the SuperBuild configure the child build to use Clang and this flag?
> And Bob's your uncle...
Hmm, to be honest I hadn't tried. It works better than expected but...
The problem for this particular project is that it doesn't file a very
standard compilation process. It compiles to LLVM IR, then to LLVM
bitcode and then it invokes and external program to generate source
files with the LLVM bitcode embedded in specially named arrays these
generated source files then are compiled along with other sources into
the projects main library. If I made the external project create
OBJECT libraries rather than regular libraries then that might work
but when I add the ``-emit-llvm`` flag to CMAKE_C_FLAGS things start
breaking..., e.g.
```
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-g" SUPPORTS_DEBUG)
```
Checking this compiler flag fails if CMAKE_C_FLAGS contains
``-emit-llvm`` due to linking errors.
I also need a way of communicating to the outside world where the
object files are as they are the final output. Using ``add_library(foo
OBJECT ...)`` is just a hack to avoid invoking the linker.
Maybe I should use a tool-chain file? I've never used this feature of
CMake before but perhaps that would solve these problems. That way I
could have CMake use, llvm-link rather than the system linker. Then
things wouldn't break when trying to link.
Dan.
More information about the CMake
mailing list