premake.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. -- premake gets a tiny bit confused if the same project appears in multiple
  2. -- solutions in a single run. premake adds a bogus $projectname path to the
  3. -- intermediate objects directory in that case. work-around using multiple
  4. -- invocations of premake and a custom option to distinguish them.
  5. MPT_PREMAKE_VERSION = ""
  6. MPT_PREMAKE_VERSION = "5.0"
  7. newoption {
  8. trigger = "group",
  9. value = "PROJECTS",
  10. description = "OpenMPT project group",
  11. allowed = {
  12. { "libopenmpt-all", "libopenmpt-all" },
  13. { "libopenmpt_test", "libopenmpt_test" },
  14. { "libopenmpt", "libopenmpt" },
  15. { "libopenmpt-small", "libopenmpt-small" },
  16. { "in_openmpt", "in_openmpt" },
  17. { "xmp-openmpt", "xmp-openmpt" },
  18. { "openmpt123", "openmpt123" },
  19. { "PluginBridge", "PluginBridge" },
  20. { "OpenMPT", "OpenMPT" },
  21. { "all-externals", "all-externals" }
  22. }
  23. }
  24. newoption {
  25. trigger = "winxp",
  26. description = "Generate XP targetting projects",
  27. }
  28. newoption {
  29. trigger = "win7",
  30. description = "Generate Windows 7 Desktop targetting projects",
  31. }
  32. newoption {
  33. trigger = "win81",
  34. description = "Generate Windows 8.1 Desktop targetting projects",
  35. }
  36. newoption {
  37. trigger = "win10",
  38. description = "Generate Windows 10 Desktop targetting projects",
  39. }
  40. newoption {
  41. trigger = "uwp",
  42. description = "Generate Windows UWP targetting projects",
  43. }
  44. newoption {
  45. trigger = "clang",
  46. description = "ClangCL projects",
  47. }
  48. mpt_projectpathname = _ACTION
  49. mpt_bindirsuffix = ""
  50. mpt_bindirsuffix32 = ""
  51. mpt_bindirsuffix64 = ""
  52. if _OPTIONS["uwp"] then
  53. allplatforms = { "x86", "x86_64", "arm", "arm64" }
  54. trkplatforms = { "x86", "x86_64", "arm", "arm64" }
  55. mpt_projectpathname = mpt_projectpathname .. "uwp"
  56. mpt_bindirsuffix = mpt_bindirsuffix .. "uwp"
  57. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "uwp"
  58. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "uwp"
  59. elseif _OPTIONS["win10"] then
  60. allplatforms = { "x86", "x86_64", "arm", "arm64" }
  61. trkplatforms = { "x86", "x86_64", "arm", "arm64" }
  62. mpt_projectpathname = mpt_projectpathname .. "win10"
  63. mpt_bindirsuffix = mpt_bindirsuffix .. "win10"
  64. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "win10"
  65. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "win10"
  66. elseif _OPTIONS["win81"] then
  67. allplatforms = { "x86", "x86_64" }
  68. trkplatforms = { "x86", "x86_64" }
  69. mpt_projectpathname = mpt_projectpathname .. "win81"
  70. mpt_bindirsuffix = mpt_bindirsuffix .. "win81"
  71. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "win81"
  72. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "win81"
  73. elseif _OPTIONS["win7"] then
  74. allplatforms = { "x86", "x86_64" }
  75. trkplatforms = { "x86", "x86_64" }
  76. mpt_projectpathname = mpt_projectpathname .. "win7"
  77. mpt_bindirsuffix = mpt_bindirsuffix .. "win7"
  78. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "win7"
  79. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "win7"
  80. elseif _OPTIONS["winxp"] then
  81. allplatforms = { "x86", "x86_64" }
  82. trkplatforms = { "x86", "x86_64" }
  83. mpt_projectpathname = mpt_projectpathname .. "winxp"
  84. mpt_bindirsuffix = mpt_bindirsuffix .. "winxp"
  85. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "winxp"
  86. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "winxp"
  87. end
  88. if _OPTIONS["clang"] then
  89. mpt_projectpathname = mpt_projectpathname .. "clang"
  90. mpt_bindirsuffix = mpt_bindirsuffix .. "clang"
  91. mpt_bindirsuffix32 = mpt_bindirsuffix32 .. "clang"
  92. mpt_bindirsuffix64 = mpt_bindirsuffix64 .. "clang"
  93. end
  94. if _OPTIONS["group"] == "libopenmpt_test" then
  95. solution "libopenmpt_test"
  96. startproject "libopenmpt_test"
  97. location ( "../../build/" .. mpt_projectpathname )
  98. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  99. platforms ( allplatforms )
  100. dofile "../../build/premake/premake-defaults-solution.lua"
  101. dofile "../../build/premake/mpt-libopenmpt_test.lua"
  102. dofile "../../build/premake/ext-mpg123.lua"
  103. dofile "../../build/premake/ext-ogg.lua"
  104. dofile "../../build/premake/ext-vorbis.lua"
  105. dofile "../../build/premake/ext-zlib.lua"
  106. end
  107. if _OPTIONS["group"] == "in_openmpt" then
  108. solution "in_openmpt"
  109. startproject "in_openmpt"
  110. location ( "../../build/" .. mpt_projectpathname )
  111. configurations { "Debug", "Release", "Checked" }
  112. platforms { "x86" }
  113. dofile "../../build/premake/premake-defaults-solution.lua"
  114. dofile "../../build/premake/mpt-in_openmpt.lua"
  115. dofile "../../build/premake/mpt-libopenmpt.lua"
  116. dofile "../../build/premake/ext-mpg123.lua"
  117. dofile "../../build/premake/ext-ogg.lua"
  118. dofile "../../build/premake/ext-vorbis.lua"
  119. dofile "../../build/premake/ext-zlib.lua"
  120. end
  121. if _OPTIONS["group"] == "xmp-openmpt" then
  122. solution "xmp-openmpt"
  123. startproject "xmp-openmpt"
  124. location ( "../../build/" .. mpt_projectpathname )
  125. configurations { "Debug", "Release", "Checked" }
  126. platforms { "x86" }
  127. dofile "../../build/premake/premake-defaults-solution.lua"
  128. dofile "../../build/premake/mpt-xmp-openmpt.lua"
  129. dofile "../../build/premake/mpt-libopenmpt.lua"
  130. dofile "../../build/premake/ext-mpg123.lua"
  131. dofile "../../build/premake/ext-ogg.lua"
  132. dofile "../../build/premake/ext-pugixml.lua"
  133. dofile "../../build/premake/ext-vorbis.lua"
  134. dofile "../../build/premake/ext-zlib.lua"
  135. end
  136. if _OPTIONS["group"] == "libopenmpt-small" then
  137. solution "libopenmpt-small"
  138. startproject "libopenmpt-small"
  139. location ( "../../build/" .. mpt_projectpathname )
  140. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  141. platforms ( allplatforms )
  142. dofile "../../build/premake/premake-defaults-solution.lua"
  143. dofile "../../build/premake/mpt-libopenmpt-small.lua"
  144. dofile "../../build/premake/ext-minimp3.lua"
  145. dofile "../../build/premake/ext-miniz.lua"
  146. dofile "../../build/premake/ext-stb_vorbis.lua"
  147. end
  148. -- should stay the last libopenmpt solution in order to overwrite the libopenmpt base project with all possible configurations
  149. if _OPTIONS["group"] == "libopenmpt" then
  150. solution "libopenmpt"
  151. startproject "libopenmpt"
  152. location ( "../../build/" .. mpt_projectpathname )
  153. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  154. platforms ( allplatforms )
  155. dofile "../../build/premake/premake-defaults-solution.lua"
  156. dofile "../../build/premake/mpt-libopenmpt.lua"
  157. if not _OPTIONS["uwp"] then
  158. dofile "../../build/premake/mpt-libopenmpt_examples.lua"
  159. end
  160. dofile "../../build/premake/ext-mpg123.lua"
  161. dofile "../../build/premake/ext-ogg.lua"
  162. if not _OPTIONS["uwp"] then
  163. dofile "../../build/premake/ext-portaudio.lua"
  164. dofile "../../build/premake/ext-portaudiocpp.lua"
  165. end
  166. dofile "../../build/premake/ext-vorbis.lua"
  167. dofile "../../build/premake/ext-zlib.lua"
  168. end
  169. if _OPTIONS["group"] == "openmpt123" then
  170. solution "openmpt123"
  171. startproject "openmpt123"
  172. location ( "../../build/" .. mpt_projectpathname )
  173. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  174. platforms ( allplatforms )
  175. dofile "../../build/premake/premake-defaults-solution.lua"
  176. dofile "../../build/premake/mpt-openmpt123.lua"
  177. dofile "../../build/premake/mpt-libopenmpt.lua"
  178. dofile "../../build/premake/ext-flac.lua"
  179. dofile "../../build/premake/ext-mpg123.lua"
  180. dofile "../../build/premake/ext-ogg.lua"
  181. dofile "../../build/premake/ext-portaudio.lua"
  182. dofile "../../build/premake/ext-vorbis.lua"
  183. dofile "../../build/premake/ext-zlib.lua"
  184. end
  185. if _OPTIONS["group"] == "PluginBridge" then
  186. solution "PluginBridge"
  187. startproject "PluginBridge"
  188. location ( "../../build/" .. mpt_projectpathname )
  189. configurations { "Debug", "Release", "Checked" }
  190. platforms ( trkplatforms )
  191. dofile "../../build/premake/premake-defaults-solution.lua"
  192. dofile "../../build/premake/mpt-PluginBridge.lua"
  193. end
  194. if _OPTIONS["group"] == "OpenMPT" then
  195. charset = "Unicode"
  196. stringmode = "UTF8"
  197. solution "OpenMPT-UTF8"
  198. startproject "OpenMPT-UTF8"
  199. location ( "../../build/" .. mpt_projectpathname )
  200. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  201. platforms ( trkplatforms )
  202. dofile "../../build/premake/premake-defaults-solution.lua"
  203. dofile "../../build/premake/mpt-OpenMPT.lua"
  204. dofile "../../build/premake/mpt-PluginBridge.lua"
  205. dofile "../../build/premake/mpt-updatesigntool.lua"
  206. dofile "../../build/premake/ext-ancient.lua"
  207. dofile "../../build/premake/ext-flac.lua"
  208. dofile "../../build/premake/ext-lame.lua"
  209. dofile "../../build/premake/ext-lhasa.lua"
  210. dofile "../../build/premake/ext-minizip.lua"
  211. dofile "../../build/premake/ext-mpg123.lua"
  212. dofile "../../build/premake/ext-ogg.lua"
  213. dofile "../../build/premake/ext-opus.lua"
  214. dofile "../../build/premake/ext-opusenc.lua"
  215. dofile "../../build/premake/ext-opusfile.lua"
  216. dofile "../../build/premake/ext-portaudio.lua"
  217. dofile "../../build/premake/ext-r8brain.lua"
  218. dofile "../../build/premake/ext-rtaudio.lua"
  219. dofile "../../build/premake/ext-rtmidi.lua"
  220. dofile "../../build/premake/ext-smbPitchShift.lua"
  221. dofile "../../build/premake/ext-soundtouch.lua"
  222. dofile "../../build/premake/ext-UnRAR.lua"
  223. dofile "../../build/premake/ext-vorbis.lua"
  224. dofile "../../build/premake/ext-zlib.lua"
  225. charset = "MBCS"
  226. stringmode = "WCHAR"
  227. solution "OpenMPT-ANSI"
  228. startproject "OpenMPT-ANSI"
  229. location ( "../../build/" .. mpt_projectpathname )
  230. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  231. platforms ( trkplatforms )
  232. dofile "../../build/premake/premake-defaults-solution.lua"
  233. dofile "../../build/premake/mpt-OpenMPT.lua"
  234. dofile "../../build/premake/mpt-PluginBridge.lua"
  235. dofile "../../build/premake/mpt-updatesigntool.lua"
  236. dofile "../../build/premake/ext-ancient.lua"
  237. dofile "../../build/premake/ext-flac.lua"
  238. dofile "../../build/premake/ext-lame.lua"
  239. dofile "../../build/premake/ext-lhasa.lua"
  240. dofile "../../build/premake/ext-minizip.lua"
  241. dofile "../../build/premake/ext-mpg123.lua"
  242. dofile "../../build/premake/ext-ogg.lua"
  243. dofile "../../build/premake/ext-opus.lua"
  244. dofile "../../build/premake/ext-opusenc.lua"
  245. dofile "../../build/premake/ext-opusfile.lua"
  246. dofile "../../build/premake/ext-portaudio.lua"
  247. dofile "../../build/premake/ext-r8brain.lua"
  248. dofile "../../build/premake/ext-rtaudio.lua"
  249. dofile "../../build/premake/ext-rtmidi.lua"
  250. dofile "../../build/premake/ext-smbPitchShift.lua"
  251. dofile "../../build/premake/ext-soundtouch.lua"
  252. dofile "../../build/premake/ext-UnRAR.lua"
  253. dofile "../../build/premake/ext-vorbis.lua"
  254. dofile "../../build/premake/ext-zlib.lua"
  255. charset = "Unicode"
  256. stringmode = "WCHAR"
  257. solution "OpenMPT"
  258. startproject "OpenMPT"
  259. location ( "../../build/" .. mpt_projectpathname )
  260. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  261. platforms ( trkplatforms )
  262. dofile "../../build/premake/premake-defaults-solution.lua"
  263. dofile "../../build/premake/mpt-OpenMPT.lua"
  264. dofile "../../build/premake/mpt-PluginBridge.lua"
  265. dofile "../../build/premake/mpt-updatesigntool.lua"
  266. dofile "../../build/premake/ext-ancient.lua"
  267. dofile "../../build/premake/ext-flac.lua"
  268. dofile "../../build/premake/ext-lame.lua"
  269. dofile "../../build/premake/ext-lhasa.lua"
  270. dofile "../../build/premake/ext-minizip.lua"
  271. dofile "../../build/premake/ext-mpg123.lua"
  272. dofile "../../build/premake/ext-ogg.lua"
  273. dofile "../../build/premake/ext-opus.lua"
  274. dofile "../../build/premake/ext-opusenc.lua"
  275. dofile "../../build/premake/ext-opusfile.lua"
  276. dofile "../../build/premake/ext-portaudio.lua"
  277. dofile "../../build/premake/ext-r8brain.lua"
  278. dofile "../../build/premake/ext-rtaudio.lua"
  279. dofile "../../build/premake/ext-rtmidi.lua"
  280. dofile "../../build/premake/ext-smbPitchShift.lua"
  281. dofile "../../build/premake/ext-soundtouch.lua"
  282. dofile "../../build/premake/ext-UnRAR.lua"
  283. dofile "../../build/premake/ext-vorbis.lua"
  284. dofile "../../build/premake/ext-zlib.lua"
  285. end
  286. -- overwrite all external projects once again with the full matrix of possible build config combinations
  287. if _OPTIONS["group"] == "all-externals" then
  288. solution "all-externals"
  289. location ( "../../build/" .. mpt_projectpathname .. "/ext" )
  290. configurations { "Debug", "Release", "Checked", "DebugShared", "ReleaseShared", "CheckedShared" }
  291. platforms ( allplatforms )
  292. dofile "../../build/premake/premake-defaults-solution.lua"
  293. dofile "../../build/premake/ext-ancient.lua"
  294. dofile "../../build/premake/ext-flac.lua"
  295. dofile "../../build/premake/ext-lame.lua"
  296. dofile "../../build/premake/ext-lhasa.lua"
  297. dofile "../../build/premake/ext-minimp3.lua"
  298. dofile "../../build/premake/ext-miniz.lua"
  299. dofile "../../build/premake/ext-minizip.lua"
  300. dofile "../../build/premake/ext-mpg123.lua"
  301. dofile "../../build/premake/ext-ogg.lua"
  302. dofile "../../build/premake/ext-opus.lua"
  303. dofile "../../build/premake/ext-opusenc.lua"
  304. dofile "../../build/premake/ext-opusfile.lua"
  305. dofile "../../build/premake/ext-portaudio.lua"
  306. dofile "../../build/premake/ext-portaudiocpp.lua"
  307. dofile "../../build/premake/ext-pugixml.lua"
  308. dofile "../../build/premake/ext-r8brain.lua"
  309. dofile "../../build/premake/ext-rtaudio.lua"
  310. dofile "../../build/premake/ext-rtmidi.lua"
  311. dofile "../../build/premake/ext-smbPitchShift.lua"
  312. dofile "../../build/premake/ext-soundtouch.lua"
  313. dofile "../../build/premake/ext-stb_vorbis.lua"
  314. dofile "../../build/premake/ext-UnRAR.lua"
  315. dofile "../../build/premake/ext-vorbis.lua"
  316. dofile "../../build/premake/ext-zlib.lua"
  317. end
  318. if _OPTIONS["uwp"] then
  319. require('vstudio')
  320. local function mptGlobalsUWP(prj)
  321. if _ACTION == 'vs2022' then
  322. premake.w('<DefaultLanguage>en-US</DefaultLanguage>')
  323. premake.w('<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>')
  324. premake.w('<AppContainerApplication>true</AppContainerApplication>')
  325. premake.w('<ApplicationType>Windows Store</ApplicationType>')
  326. premake.w('<ApplicationTypeRevision>10.0</ApplicationTypeRevision>')
  327. premake.w('<WindowsTargetPlatformVersion Condition=" \'$(WindowsTargetPlatformVersion)\' == \'\' ">10.0.22000.0</WindowsTargetPlatformVersion>')
  328. premake.w('<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>')
  329. elseif _ACTION == 'vs2019' then
  330. premake.w('<DefaultLanguage>en-US</DefaultLanguage>')
  331. premake.w('<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>')
  332. premake.w('<AppContainerApplication>true</AppContainerApplication>')
  333. premake.w('<ApplicationType>Windows Store</ApplicationType>')
  334. premake.w('<ApplicationTypeRevision>10.0</ApplicationTypeRevision>')
  335. premake.w('<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>')
  336. premake.w('<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion>')
  337. end
  338. end
  339. local function mptClCompileUWP(prj)
  340. premake.w('<CompileAsWinRT>false</CompileAsWinRT>')
  341. end
  342. local function mptOutputPropertiesUWP(prj)
  343. premake.w('<IgnoreImportLibrary>false</IgnoreImportLibrary>')
  344. end
  345. local function mptProjectReferencesUWP(prj)
  346. premake.w('<ReferenceOutputAssembly>false</ReferenceOutputAssembly>')
  347. end
  348. premake.override(premake.vstudio.vc2010.elements, "globals", function(base, prj)
  349. local calls = base(prj)
  350. table.insert(calls, mptGlobalsUWP)
  351. return calls
  352. end)
  353. premake.override(premake.vstudio.vc2010.elements, "clCompile", function(base, prj)
  354. local calls = base(prj)
  355. table.insert(calls, mptClCompileUWP)
  356. return calls
  357. end)
  358. premake.override(premake.vstudio.vc2010.elements, "outputProperties", function(base, prj)
  359. local calls = base(prj)
  360. table.insert(calls, mptOutputPropertiesUWP)
  361. return calls
  362. end)
  363. premake.override(premake.vstudio.vc2010.elements, "projectReferences", function(base, prj)
  364. local calls = base(prj)
  365. table.insert(calls, mptProjectReferencesUWP)
  366. return calls
  367. end)
  368. end