Correctly declare variables in post build?

CodeLite installation/troubleshooting forum
CrHasher
CodeLite Curious
Posts: 1
Joined: Thu Jan 09, 2014 1:00 pm
Genuine User: Yes
IDE Question: C++
Contact:

Correctly declare variables in post build?

Post by CrHasher »

I’m trying to copy some files after build by using the post build step in project settings. I would like to declare a variable so I don’t have to repeat the same thing over and over again.

What I tried so far and can’t get this to work:
  • TARGET_PATH=./pathpart1/pathpart2
    cp –f lib.a $TARGET_PATH
    cp –f lib.dll $TARGET_PATH
    - tries to copy lib.a and lib.dll to ARGET_PATH
  • TARGET_PATH:=./pathpart1/pathpart2
    cp –f lib.a $(TARGET_PATH)
    cp –f lib.dll $(TARGET_PATH)
    - says that ./pathpart1/pathpart2 directory does not exist even though running and echoing pwd outputs the path to the dir where ./pathpart1/pathpart2 exists.
This works but I don’t like it:
  • cp –f lib.a ./pathpart1/pathpart2
    cp –f lib.dll ./pathpart1/pathpart2 <- same path repeated
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Correctly declare variables in post build?

Post by eranif »

CrHasher wrote:TARGET_PATH=./pathpart1/pathpart2
Assuming you are using the default build system of codelite ( i.e. no custom makefiles ) the post build commands are created as part of the generated makefile ( <Project Name>.mk )

This means, that this line:

Code: Select all

TARGET_PATH=./pathpart1/pathpart2
is an invalid Makefile command - so it will not work

If you want to declare a variable is by using the environment variables.
There are 2 ways to do it:

project settings -> common settings -> environment
and define the environment variable there:

Code: Select all

TARGET_PATH=./pathpart1/pathpart2
And in your post-build tab, use it like this:

Code: Select all

cp –f lib.a $(TARGET_PATH)
The second way to define the environment variable as global from : settings -> environment variables (the rest is the same)

Eran
Make sure you have read the HOW TO POST thread
Post Reply