forked from Enhex/premake-cmake
-
Notifications
You must be signed in to change notification settings - Fork 7
/
_preload.lua
72 lines (59 loc) · 1.58 KB
/
_preload.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
69
70
71
72
--
-- Name: _preload.lua
-- Purpose: Define the cmake action.
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Andrew Gough
-- Manu Evans
-- Yehonatan Ballas
-- UndefinedVertex
-- Created: 2013/05/06
-- Copyright: (c) 2008-2020 Jason Perkins and the Premake project
--
local p = premake
-- support cmake executable_suffix
p.api.register {
name = "executable_suffix",
scope = "config",
kind = "string",
}
local default_toolset_map = {
["windows"] = "msc-v142", -- Visual Studio 2019
["macosx"] = "clang",
["linux"] = "gcc",
["_"] = "gcc", -- default
}
local default_toolset = default_toolset_map[os.target()] or default_toolset_map["_"]
newaction
{
-- Metadata for the command line and help system
trigger = "cmake",
shortname = "CMake",
description = "Generate CMake file",
toolset = default_toolset,
-- The capabilities of this action
valid_kinds = { "ConsoleApp", "WindowedApp", "Makefile", "SharedLib", "StaticLib", "Utility" },
valid_languages = { "C", "C++" },
valid_tools = {
cc = { "gcc", "clang", "msc" }
},
-- Workspace and project generation logic
onWorkspace = function(wks)
p.modules.cmake.generateWorkspace(wks)
end,
onProject = function(prj)
p.modules.cmake.generateProject(prj)
end,
onCleanWorkspace = function(wks)
p.modules.cmake.cleanWorkspace(wks)
end,
onCleanProject = function(prj)
p.modules.cmake.cleanProject(prj)
end,
}
--
-- Decide when the full module should be loaded.
--
return function(cfg)
return (_ACTION == "cmake")
end