[CMake] Best way to modify C++ build steps (clang / linux)?

Christian Convey christian.convey at gmail.com
Mon Jun 20 11:28:07 EDT 2016


I've got an existing project with a CMake-based build system.  The project:

   - Has both C and C++ files
   - Links some ".o" files into convenience .a files.
   - Links some ".o" and ".a" files into several different executables.
   - Can be built successfully with gcc or clang.

When using clang, I'd like the build process to *not* directly compile a
C/C++ source file into an object file.  Instead, I'd like it to use two
distinct steps:

   1. Use "clang -emit-llvm ..." to produce a bitcode (".bc") file.
   2. Use "llc" to compile the bitcode file to a native ".o" file.

Does CMake have an idiomatic way to implement this change?

(Worst-case scenario I can create a wrapper script for "clang" which
performs those two steps separately.  But I'd rather use the intended
approach if possible.)

- Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160620/4e120619/attachment.html>


More information about the CMake mailing list