huangcm
2025-09-01 53d8e046ac1bf2ebe94f671983e3d3be059df91a
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--
-- Requires: Premake 5 (https://premake.github.io/)
-- Usage: premake5 --file=premake5.lua [project / makefile format, refer to premake5 --help] --target=[target from below]
--
 
-- target option
tbl_target_values =
{
   { "windows", "VS2015 projects targeting Windows 32/64 bits" },
   { "macosx", "Xcode4 projects targeting OS X" },
}
 
newoption
{
   trigger = "target",
   description = "Build environment and target to generate projects for.",
   allowed = tbl_target_values
}
 
-- validation
target_env = _OPTIONS["target"]
if not target_env then
   print "Command-line option --target is required with one of the following values:"
   for _, v in ipairs(tbl_target_values) do
       print(v[1])
   end
   os.exit(1)
end
 
-- solution
workspace "tinyxml2"
 
   tbl_platforms = {}
    if target_env == "windows" then
        tbl_platforms = {
            "x86",
            "x64",
        }
    elseif target_env == "macosx" then
        tbl_platforms = {
            "Universal64"
        }
    end
   platforms(tbl_platforms)
 
   tbl_configurations = {
       "Debug",
       "Release",
   }
   configurations(tbl_configurations)
 
   sln_location = ".projects/"..target_env
   location(sln_location)
 
   bin_location = ".artifacts/"..target_env
   obj_location = ".intermediate/"..target_env
 
   for _, p in ipairs(tbl_platforms) do
       for _, c in ipairs(tbl_configurations) do
           local pc = p.."-"..c
           filter{ "platforms:"..p, c }
               targetdir(bin_location.."/"..pc)
               libdirs(bin_location.."/"..pc)
               objdir(obj_location.."/"..pc)
       end
   end
 
   filter("not Release")
       optimize "Debug"
       symbols "On"
   filter{ "Release" }
       optimize "Full"
   filter{}
 
   -- projects
   project "tinyxml2"
 
       kind "staticlib"
 
       files {
           "tinyxml2.h",
           "tinyxml2.cpp"
       }
 
   project "xmltest"
 
       kind "consoleapp"
 
       links {
           "tinyxml2"
       }
 
       files {
           "xmltest.cpp"
        }