Improve CC detection using premake

Before premake 5.0.0-beta3 if --cc wasn't specified the gnu make default
was used unless overridden via env.

Now premake always chooses a compiler sidestepping gnu make choice. So
use the premake pick unless explicitly overridden via CC in env or via
option to premake.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser
2024-12-15 07:52:39 +01:00
parent ead2fbc115
commit d5f4c812ea
+8 -18
View File
@@ -42,25 +42,15 @@ newoption { category = "Pyrogenesis", trigger = "libdir", description = "Directo
-- Root directory of project checkout relative to this .lua file
rootdir = "../.."
-- detect compiler for non-Windows
if os.istarget("macosx") then
cc = "clang"
elseif os.istarget("bsd") and os.getversion().description == "FreeBSD" then
cc = "clang"
elseif not os.istarget("windows") then
-- Determine C compiler
local cc = nil
if os.getenv("CC") then
cc = os.getenv("CC")
if cc == nil or cc == "" then
local hasgcc = os.execute("which gcc > .gccpath")
local f = io.open(".gccpath", "r")
local gccpath = f:read("*line")
f:close()
os.execute("rm .gccpath")
if gccpath == nil then
cc = "clang"
else
cc = "gcc"
end
end
elseif _OPTIONS["cc"] then
cc = _OPTIONS["cc"]
else
-- assumes cc name is toolset name
cc = premake.action.current().toolset
end
-- detect CPU architecture (simplistic)