Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: huycan on May 02, 2020, 09:49:12 AM

Title: AddLinkLib to Target in Wizard - prepending policy
Post by: huycan on May 02, 2020, 09:49:12 AM
I am creating a wizard... and I have a question. The command AddLinkLib add a lib to target with an appending policy. What's the command for prepending instead?
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: oBFusCATed on May 02, 2020, 11:09:02 AM
Check the docs here: http://wiki.codeblocks.org/index.php/Scripting_commands#CompileOptionsBase

I suppose you can use GetLinkLibs and then use SetLinkLibs. Or build an array of libs and then set it at the end. It is up to you.
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: huycan on May 02, 2020, 09:54:03 PM
What I want to do is this:

At the Project level... I just AddLinkLib.. as usual...

Then at the Target level... AddLinkLib action is default to orAppendToParentOptions... so the question how can I change it to --> orPrependToParentOptions...
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: oBFusCATed on May 02, 2020, 11:51:53 PM
For this you use CompileTargetBase::GetOptionRelation and CompileTargetBase::SetOptionRelation, I think.
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: huycan on May 03, 2020, 12:56:48 AM
Perfect! Thanks. That did it. I use target.SetOptionRelation(ortLinkerOptions, 2);
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: oBFusCATed on May 03, 2020, 01:28:27 AM
You can use one of the enum OptionsRelation names instead of plain 2. It is shown in the docs on the page I've linked.
Title: Re: AddLinkLib to Target in Wizard - prepending policy
Post by: huycan on May 03, 2020, 01:41:07 AM
Yes, I know. I was just do a quick test. I use the constant "orPrependToParentOptions" mentioned above. The final code is:

target.SetOptionRelation(ortLinkerOptions, orPrependToParentOptions);
target.AddLinkLib(_T("TheLib"));

Anyway, thanks again.