-
-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom command in cmake generator #1735
Comments
(i forgot to precise that this is a feature request) |
Currently only rule+after_buildcmd and on_buildcmd_file support build commands. I remember that the makefile and compile_commands generators already support them, but the cmake generator does not yet support them. I will consider this feature later, please be patient. |
https://cmake.org/cmake/help/latest/command/add_custom_command.html Something may help. For custom rules we can extract the code snippets and use add_custom_command to invoke |
ADD_CUSTOM_COMMAND and PRE_BUILD did not work as I expected. https://gitlab.kitware.com/cmake/cmake/-/issues/17802 [ 50%] Building C object CMakeFiles/test.dir/src/main.c.o
[100%] Linking C executable build/macosx/x86_64/debug/test
do pre_build |
I have supported it. we need use rule with batchcmds to support it. rule:
rule("foo")
after_buildcmd(function (target, batchcmds, opt)
batchcmds:show("hello xmake!")
batchcmds:cp("xmake.lua", "/tmp/")
-- batchcmds:execv("echo", {"hello", "world!"})
-- batchcmds:runv("echo", {"hello", "world!"})
end)
target("test")
set_kind("binary")
add_rules("foo")
add_files("src/*.c") CMakelists.txt
|
Thank you very much, you are incredibly efficient ! |
We can also run a full xmake script file rule("foo")
after_buildcmd(function (target, batchcmds, opt)
batchcmds:execv("xmake", {"lua", path.join(os.scriptdir(), "myscript.lua")})
end) |
That's really nice! However I think it's better using a platform independent command other than |
This will additionally rely on xmake, which is inconvenient for external distribution. But |
To make it more robust |
Thanks, I have improved it. |
A command to copy folders/files that can be translated automaticaly to cmake
I use CLion, and one of my projects require the use of an asset folder. I know how to make a simple copy cmd in xmake using lua, but when i generate a cmake from this, that cmd is just ignored and the app just crash at runtime unless i manually copy files.
I actually use this method :
A good solution I thought about is to maybe create a xmake command to directly copy files/folder afterbuild, that can be automatically translated to cmake.
Thank you for your job on this project, I hope this will be considerated.
If there is already a solution to this problem, I apologize.
The text was updated successfully, but these errors were encountered: