Author Topic: Changing build target according to a #define  (Read 4668 times)

Offline Lefteris

  • Multiple posting newcomer
  • *
  • Posts: 14
Changing build target according to a #define
« on: May 18, 2011, 03:28:26 am »
Hello,

I did a quick search but could not find an answer to my question so I will ask about it here. I have a project which depending on a #define flag should compile different files. Later in the future when I will distribute it I guess I will have to include a normal makefile but for now I would like to use the pre-build script step of Codeblocks. I have made 4 different virtual build targets (2 debug and 2 release). I can not understand what syntax I should use in the pre-script. A pseudocode would be
Code
if(DEBUG) {    if(FLAG_DEFINED){Build Debug_FD }else{Build Debug}           }
else {             if(FLAG_DEFINED){Build Release_FD }else{Build Release}           }

I do know ofcourse that I can just pick the builds from the drop down menu on the top left of the Codeblocks GUI, but since it should be later done by a makefile I want to test it this way too. Hope I make sense.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 640
Re: Changing build target according to a #define
« Reply #1 on: May 25, 2011, 05:56:23 pm »
In 'project/build options/compiler settings/#defines' for a specific target u can insert ur definition like
Code
FLAG_DEFINED
Then in the source insert
Code
#ifdef FLAG_DEFINED
do this
#else
do that
#endif

That's what I understand from ur post, sry if unrelated.