I would like to build my application using clang when generating a Makefile (gmake toolchain). Is there a way to do this?
-
premake 5 has the option: `--cc=VALUE`. It doesn't work for me though - I always get GCC. – user2023370 Jan 06 '16 at 23:46
-
I know this question is old enough, but would like to ask is that possible to let premake to build it with precisely clang++ instead of clang? – Lasven Loke Dec 23 '22 at 13:14
5 Answers
Here is what I use, it works for me:
-- ugly hack to use clang
premake.gcc.cc = 'clang'
premake.gcc.cxx = 'clang++'
Nothing else seemed to work at all.

- 2,640
- 2
- 21
- 21
On premake5, use
#!/bin/bash
premake-5.0.0-alpha11-linux --file=PA7.lua --cc=clang --verbose gmake
--cc=clang
is analogue of --platform option in premake4.

- 721
- 9
- 23
I ultimately ended up doing what @Burton Samograd did: assign the CC environment variable. However, buried deep in the premake4 message boards they do have a way to define a new platform.
When using premake4, just invoke:
premake4 --platform=clang gmake
The only problem I've found with this is it didn't work as I expected. I'm giving my vote to Burton, but the information is here if you want it.

- 7,842
- 2
- 47
- 62

- 83
- 1
- 7
-
1When I try this I just get: `Error: invalid value 'clang' for option 'platform'.` – leetNightshade Dec 02 '15 at 03:49
-
This is now an error in premake 5: `Error: invalid option 'platform'`. – user2023370 Jan 06 '16 at 23:42
It looks like you can just set the CC varaible:
CC ?= /usr/bin/clang
in your premake file. The ?= only sets it if you haven't set it in your environment.

- 3,652
- 19
- 21
-
5The whole purpose of premake is to generate these files automatically. You should never, ever have to modify them. – Alex Pana May 25 '13 at 17:21
-
If you have premake 5, you can set the toolset
option to clang
in your premake5.lua
toolset "clang"
in premake5.lua