Hi CMakers,<div><br></div><div>I am trying to use CMake with llvm-gcc compiler (<a href="http://llvm.org/cmds/llvmgcc.html" target="_blank">http://llvm.org/cmds/llvmgcc.html</a>) and want to split the compilation into three steps:</div>
<div>
<br></div><div>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></div><div>
2. Compile bitcode into assembly language using llc with the command llc -o <assembly> <bitcode></div><div>3. Translate assembly language into object code using GNU assembler with the command as -o <object> <assembly></div>
<div><br></div><div>The reason for this is that I need both the object files and the bitcode files be generated.</div><div>However I can't figure out how to accomplish this.</div><div><br></div><div>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:</div>
<div><br></div><div><div>string(REPLACE "<OBJECT>" "<OBJECT>.bc"</div><div> generate_bc ${CMAKE_CXX_COMPILE_OBJECT})</div></div><div><br></div><div><div>set(CMAKE_CXX_COMPILE_OBJECT</div>
<div> "${CMAKE_CXX_COMPILE_OBJECT} && ${generate_bc} -emit-llvm")</div></div><div><br></div><div>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).</div>
<div>Is there a better solution to this problem?</div><div><br></div><div>Best regards,</div><div>Victor</div>