forked from Enhex/premake-cmake
-
Notifications
You must be signed in to change notification settings - Fork 7
/
cmake.lua
68 lines (53 loc) · 1.61 KB
/
cmake.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--
-- Name: cmake.lua
-- Purpose: Define the cmake action(s).
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Andrew Gough
-- Manu Evans
-- Jason Perkins
-- Yehonatan Ballas
-- Created: 2013/05/06
-- Copyright: (c) 2008-2020 Jason Perkins and the Premake project
--
local p = premake
p.modules.cmake = {}
p.modules.cmake._VERSION = p._VERSION
local cmake = p.modules.cmake
local project = p.project
function cmake.generateWorkspace(wks)
p.eol("\r\n")
p.indent(" ")
p.generate(wks, "CMakeLists.txt", cmake.workspace.generate)
end
function cmake.generateProject(prj)
p.eol("\r\n")
p.indent(" ")
if project.isc(prj) or project.iscpp(prj) then
p.generate(prj, ".cmake", cmake.project.generate)
end
end
local function normalize_identifier(name)
local res = string.gsub(name, "[^a-zA-Z0-9_]", "_")
if res ~= name then
premake.warnOnce("cmake_identifier_" .. name, 'configuration "' .. name .. '" contains unsuported characters, replaced by "' .. res .. '"')
end
return res
end
function cmake.cfgname(cfg)
if cmake.workspace.multiplePlatforms then
return string.format("%s_%s", normalize_identifier(cfg.platform), normalize_identifier(cfg.buildcfg))
else
return normalize_identifier(cfg.buildcfg)
end
end
function cmake.cleanWorkspace(wks)
p.clean.file(wks, "CMakeLists.txt")
end
function cmake.cleanProject(prj)
p.clean.file(prj, prj.name .. ".cmake")
end
include("cmake_workspace.lua")
include("cmake_project.lua")
include("_preload.lua")
return cmake