6

I would like to build my application using clang when generating a Makefile (gmake toolchain). Is there a way to do this?

Tamás Szelei
  • 23,169
  • 18
  • 105
  • 180
  • 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 Answers5

7

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.

Frank
  • 2,640
  • 2
  • 21
  • 21
4

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.

sdd
  • 721
  • 9
  • 23
2

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.

Massimiliano
  • 7,842
  • 2
  • 47
  • 62
JRL
  • 83
  • 1
  • 7
1

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.

Burton Samograd
  • 3,652
  • 19
  • 21
0

If you have premake 5, you can set the toolset option to clangin your premake5.lua

toolset "clang" in premake5.lua