User forums > General (but related to Code::Blocks)
Copying a target
(1/1)
johne53:
After building a target with C::B, suppose I want to copy it to another folder (e.g. I had a workspace building 5 x DLL's or Shared Objects and I wanted to copy them all into a common folder). I assume I'd have to do this as a post-build step. Can anyone tell me what the appropriate command would be?
johne53:
Can no-one suggest a suitable post-build command line?
(preferably one that works for both Windows and Linux).
thomas:
You can use the $(TARGETNAME_OUTPUT_FILE) variable at every target's post build step, and maybe some other variable like $(PROJECT_DIR) to determine the target location (see the WiKi under "variable expansion" for a complete list of available variables). Then use the copy or cp command.
However, it's much easier to just change the output directories of all targets under "Project properties", so the libraries are created in the right location. No copying necessary.
Biplab:
--- Quote from: johne53 on September 17, 2007, 12:17:37 pm ---After building a target with C::B, suppose I want to copy it to another folder (e.g. I had a workspace building 5 x DLL's or Shared Objects and I wanted to copy them all into a common folder). I assume I'd have to do this as a post-build step. Can anyone tell me what the appropriate command would be?
--- End quote ---
1) Create a batch file for windows with the command to copy the required files and similarly create one shell script for Linux.
2) Add the following command to the Post-Build section.
--- Code: ---[[ if (PLATFORM == PLATFORM_MSW) { print("cmd /C \"test.bat\""); } else { print("/bin/sh foo.sh"); } ]]
--- End code ---
Please note that the above code won't work if it's splitted into multiple lines. Also adjust the command for Linux as I've not tested it.
You can also use the script to copy files. But that would raise a security warning (which you can disable at your wish). IMHO, the first method is the better one.
Navigation
[0] Message Index
Go to full version