mirror of
https://github.com/mamedev/mame.git
synced 2024-09-29 17:38:18 +02:00
added cmake support to genie (nw)
This commit is contained in:
parent
033227778e
commit
49fbdf3497
3 changed files with 105 additions and 0 deletions
31
3rdparty/genie/src/actions/cmake/_cmake.lua
vendored
Normal file
31
3rdparty/genie/src/actions/cmake/_cmake.lua
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
--
|
||||
-- _cmake.lua
|
||||
-- Define the CMake action(s).
|
||||
-- Copyright (c) 2015 Miodrag Milanovic
|
||||
--
|
||||
|
||||
premake.cmake = { }
|
||||
|
||||
newaction {
|
||||
trigger = "cmake",
|
||||
shortname = "CMake",
|
||||
description = "Generate CMake project files",
|
||||
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
|
||||
valid_languages = { "C", "C++" },
|
||||
valid_tools = {
|
||||
cc = { "gcc" },
|
||||
},
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "CMakeLists.txt", premake.cmake.workspace)
|
||||
end,
|
||||
onproject = function(prj)
|
||||
premake.generate(prj, "%%/CMakeLists.txt", premake.cmake.project)
|
||||
end,
|
||||
oncleansolution = function(sln)
|
||||
premake.clean.file(sln, "CMakeLists.txt")
|
||||
end,
|
||||
oncleanproject = function(prj)
|
||||
premake.clean.file(prj, "%%/CMakeLists.txt")
|
||||
end
|
||||
}
|
||||
|
60
3rdparty/genie/src/actions/cmake/cmake_project.lua
vendored
Normal file
60
3rdparty/genie/src/actions/cmake/cmake_project.lua
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
--
|
||||
-- _cmake.lua
|
||||
-- Define the CMake action(s).
|
||||
-- Copyright (c) 2015 Miodrag Milanovic
|
||||
--
|
||||
|
||||
local cmake = premake.cmake
|
||||
local tree = premake.tree
|
||||
|
||||
function cmake.files(prj)
|
||||
local tr = premake.project.buildsourcetree(prj)
|
||||
tree.traverse(tr, {
|
||||
onbranchenter = function(node, depth)
|
||||
end,
|
||||
onbranchexit = function(node, depth)
|
||||
end,
|
||||
onleaf = function(node, depth)
|
||||
_p(1, '../%s', node.cfg.name)
|
||||
end,
|
||||
}, true, 1)
|
||||
end
|
||||
|
||||
function premake.cmake.project(prj)
|
||||
io.indent = " "
|
||||
_p('cmake_minimum_required(VERSION 2.8.4)')
|
||||
_p('')
|
||||
_p('project(%s)', premake.esc(prj.name))
|
||||
_p('set(')
|
||||
_p('source_list')
|
||||
cmake.files(prj)
|
||||
_p(')')
|
||||
|
||||
local platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms, "Native")
|
||||
for i = #platforms, 1, -1 do
|
||||
if premake.platforms[platforms[i]].iscrosscompiler then
|
||||
table.remove(platforms, i)
|
||||
end
|
||||
end
|
||||
|
||||
for _, platform in ipairs(platforms) do
|
||||
for cfg in premake.eachconfig(prj, platform) do
|
||||
for _,v in ipairs(cfg.includedirs) do
|
||||
_p('include_directories(../%s)', premake.esc(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (prj.kind=='StaticLib') then
|
||||
_p('add_library(%s STATIC ${source_list})',premake.esc(prj.name))
|
||||
end
|
||||
if (prj.kind=='SharedLib') then
|
||||
_p('add_library(%s SHARED ${source_list})',premake.esc(prj.name))
|
||||
end
|
||||
if (prj.kind=='ConsoleApp') then
|
||||
_p('add_executable(%s ${source_list})',premake.esc(prj.name))
|
||||
end
|
||||
if (prj.kind=='WindowedApp') then
|
||||
_p('add_executable(%s ${source_list})',premake.esc(prj.name))
|
||||
end
|
||||
end
|
14
3rdparty/genie/src/actions/cmake/cmake_workspace.lua
vendored
Normal file
14
3rdparty/genie/src/actions/cmake/cmake_workspace.lua
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
--
|
||||
-- _cmake.lua
|
||||
-- Define the CMake action(s).
|
||||
-- Copyright (c) 2015 Miodrag Milanovic
|
||||
--
|
||||
|
||||
function premake.cmake.workspace(sln)
|
||||
_p('cmake_minimum_required(VERSION 2.8.4)')
|
||||
_p('')
|
||||
for i,prj in ipairs(sln.projects) do
|
||||
local name = premake.esc(prj.name)
|
||||
_p('add_subdirectory(%s)', name)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue