[CMake] using llvm as a c compiler
Eric Noulard
eric.noulard at gmail.com
Sun Sep 30 04:54:39 EDT 2007
2007/9/30, brad clawsie <clawsie at fastmail.fm>:
> hi.
>
> i'm a cmake newbie. i am looking for some spoonfeeding regarding
> changing my default c compiler to llvm-gcc, and how to set flags to
> it. for example:
>
> llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
>
> to compile a file hello.c
I've just discovered the existence of llvm (http://llvm.org/)
with your message.
I think you may have 2 options:
1) first consider llvm-gcc as a C compiler variant
I think you may just set CC env var before running CMake
as specified here:
http://www.cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools
Then, you may need to change some vars in you CMakeLists.txt
like CMAKE_C_OUTPUT_EXTENSION or CMAKE_C_FLAGS or
see http://www.cmake.org/Wiki/CMake_Useful_Variables
SET(CMAKE_C_OUTPUT_EXTENSION ".bc")
in order to overide the .o default.
SET(CMAKE_C_FLAGS "-emit-llvm)
in order to globally add the flasg if it is necessary
2) Consider llvm-gcc as a "cross-compiler" since the target is
llvm and not the "native object" , if I understood it well.
Then you should try CVS version of CMake which adds support
for cross-compilation:
http://www.cmake.org/Wiki/CMake_Cross_Compiling
--
Erk
More information about the CMake
mailing list