Hi CMakers,

I am trying to use CMake with llvm-gcc compiler (
http://llvm.org/cmds/llvmgcc.html) and want to split the compilation into
three steps:

1. Compile the C/C++ source code into LLVM bitcode using llvm-gcc with the
command llvm-gcc <c-flags> -emit-llvm -o <bitcode> -c <source>
2. Compile bitcode into assembly language using llc with the command llc -o
<assembly> <bitcode>
3. Translate assembly language into object code using GNU assembler with the
command as -o <object> <assembly>

The reason for this is that I need both the object files and the bitcode
files be generated.
However I can't figure out how to accomplish this.

So far the only way to invoke llvm-gcc with the correct flags I have found
is to redefine CMAKE_CXX_COMPILE_OBJECT as follows:

string(REPLACE "<OBJECT>" "<OBJECT>.bc"
    generate_bc ${CMAKE_CXX_COMPILE_OBJECT})

set(CMAKE_CXX_COMPILE_OBJECT
    "${CMAKE_CXX_COMPILE_OBJECT} && ${generate_bc} -emit-llvm")

However it invokes the compiler two times: one to generate the object file
(steps 1 - 3 combined) and one to generate the bitcode (step 1).
Is there a better solution to this problem?

Best regards,
Victor
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to