premake-cmake icon indicating copy to clipboard operation
premake-cmake copied to clipboard

Pre/Post Build Commands

Open BinaryAura opened this issue 4 years ago • 5 comments

I'm now trying to automate version bumping through prebuildcommands and gitversion. While it does generate the cmake files. cmake module ignores prebuildcommands. I assume it also ignores the postbuildcommands.

I think add_dependencies() and add_custom_target() cmake functions will help here.

I have an example in here.

oxygen.zip

BinaryAura avatar May 04 '21 13:05 BinaryAura

After a lot of review of the core gmake module adding

	local steps = prj['prebuild' .. "commands"]
	local msg = prj['prebuild' .. "message"]
	steps = os.translateCommandsAndPaths(steps, prj.project.basedir, prj.project.location)
	msg = msg or string.format("Running %s commands", "prebuild")
	
	_p('add_custom_target(')
	_p('\t"%sprebuild"', prj.name:lower())
	_p('\tCOMMAND echo %s', msg)
	_p('\t%s', table.implode(steps, "COMMAND ", "\n", "\n\tCOMMAND "))
	_p('\tWORKING_DIRECTORY %s', prj.project.basedir)
	_p(')')
	_p('add_dependencies("%s" "%sprebuild")', prj.name, prj.name:lower())

after the cfg in project.eachconfig(prj) do seems to be a temporary solution. I think to do anything much more complicated I think a refactor is called for, if for no other reason than to break up the monolith of a function that project's generate() function is. I'll be using my own fork/branch for this though.

BinaryAura avatar May 04 '21 19:05 BinaryAura

Yeah you probably should fork. I'm not using this code so I won't be improving it, so might as well fork to skip the PR bureaucracy.

Enhex avatar May 05 '21 12:05 Enhex

So is this going to be fixed? It's really frustrating that I have to copy my dll over to the exe directory.

SunnyMonster123 avatar Aug 21 '21 03:08 SunnyMonster123

fork the repo and apply the changes.

Enhex avatar Aug 21 '21 07:08 Enhex

fork the repo and apply the changes.

Ahh... The thing is, I don't know Lua that well and I definitely don't know how CMake works 😟

SunnyMonster123 avatar Aug 21 '21 07:08 SunnyMonster123