i also have similar needs as killerbot and tried to define a custom variable named <target> for each target with a different string, in the hope, that when i use the custom variable $(target) i'd get the appropriate string related to the actual selected target,
and use it in the output file, object dir and deps-dir settings.
you see the idea best when looking into the project file...
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="Target test"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
<Option pch_mode="2"/>
<Option active_target="0"/>
<Option compiler="0"/>
<Build>
<Target title="target1">
<Option output="wxapp_$(target).exe"/>
<Option working_dir="."/>
<Option object_output=".objs_$(target)"/>
<Option deps_output=".deps_$(target)"/>
<Option type="0"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="0"/>
<Environment>
<Variable name="target" value="T1"/>
</Environment>
</Target>
<Target title="target2">
<Option output="wxapp_$(target).exe"/>
<Option working_dir="."/>
<Option object_output=".objs_$(target)"/>
<Option deps_output=".deps_$(target)"/>
<Option type="0"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="0"/>
<Environment>
<Variable name="target" value="T2"/>
</Environment>
</Target>
<Target title="target3">
<Option output="wxapp_$(target).exe"/>
<Option working_dir="."/>
<Option object_output=".objs_$(target)"/>
<Option deps_output=".deps_$(target)"/>
<Option type="0"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="0"/>
<Environment>
<Variable name="target" value="T3"/>
</Environment>
</Target>
<Environment>
<Variable name="WX_DIR" value="d:\wx261"/>
<Variable name="WX_CFG" value=""/>
</Environment>
</Build>
<Compiler>
<Add option="-pipe"/>
<Add option="-mthreads"/>
<Add option="-Winvalid-pch"/>
<Add option="-include "wx_pch.h""/>
<Add option="-D__GNUWIN32__"/>
<Add option="-D__WXMSW__"/>
<Add option="-DWXUSINGDLL"/>
<Add option="-DUSE_PCH"/>
<Add directory="$(WX_DIR)\include"/>
<Add directory="$(WX_DIR)\lib\gcc_dll$(WX_CFG)\msw"/>
<Add directory="$(WX_DIR)\contrib\include"/>
</Compiler>
<ResourceCompiler>
<Add directory="$(WX_DIR)\include"/>
</ResourceCompiler>
<Linker>
<Add library="wxmsw26"/>
<Add directory="$(WX_DIR)\lib\gcc_dll$(WX_CFG)"/>
</Linker>
<Unit filename="main.cpp">
<Option compilerVar="CPP"/>
<Option target="target1"/>
<Option target="target2"/>
<Option target="target3"/>
</Unit>
<Unit filename="main.h">
<Option compilerVar=""/>
<Option compile="0"/>
<Option link="0"/>
<Option target="target1"/>
<Option target="target2"/>
<Option target="target3"/>
</Unit>
<Unit filename="wx_pch.h">
<Option compilerVar="CPP"/>
<Option link="0"/>
<Option weight="0"/>
<Option target="target1"/>
<Option target="target2"/>
<Option target="target3"/>
</Unit>
</Project>
</CodeBlocks_project_file>
this approach almost works, when the custom variable <target> isn't defined at project level but only at target levels,
but the target-dependency of this custom variable is somehow scrambled.
* when i build target1, $(target) is set to "T3",
Project : Target test
Compiler : GNU GCC Compiler (called directly)
Directory : D:\cpp\_projects\CodeBlocks\TESTS\target_test\
--------------------------------------------------------------------------------
Switching to target: target1
mingw32-g++.exe -pipe -mthreads -Winvalid-pch -include "wx_pch.h" -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DUSE_PCH -Id:\wx261\include -Id:\wx261\lib\gcc_dll\msw -Id:\wx261\contrib\include -c main.cpp -o .objs_T3\main.o
mingw32-g++.exe -Ld:\wx261\lib\gcc_dll -o wxapp_T3.exe .objs_T3\main.o -lwxmsw26 -mwindows
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
* when i build target2, $(target) is set to "T1",
Project : Target test
Compiler : GNU GCC Compiler (called directly)
Directory : D:\cpp\_projects\CodeBlocks\TESTS\target_test\
--------------------------------------------------------------------------------
Switching to target: target2
mingw32-g++.exe -pipe -mthreads -Winvalid-pch -include "wx_pch.h" -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DUSE_PCH -Id:\wx261\include -Id:\wx261\lib\gcc_dll\msw -Id:\wx261\contrib\include -c main.cpp -o .objs_T1\main.o
mingw32-g++.exe -Ld:\wx261\lib\gcc_dll -o wxapp_T1.exe .objs_T1\main.o -lwxmsw26 -mwindows
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
and finally
* when i build target3, $(target) is set to "T2"
Project : Target test
Compiler : GNU GCC Compiler (called directly)
Directory : D:\cpp\_projects\CodeBlocks\TESTS\target_test\
--------------------------------------------------------------------------------
Switching to target: target3
mingw32-g++.exe -pipe -mthreads -Winvalid-pch -include "wx_pch.h" -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DUSE_PCH -Id:\wx261\include -Id:\wx261\lib\gcc_dll\msw -Id:\wx261\contrib\include -c main.cpp -o .objs_T2\main.o
mingw32-g++.exe -Ld:\wx261\lib\gcc_dll -o wxapp_T2.exe .objs_T2\main.o -lwxmsw26 -mwindows
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
when i select build target All, $(target) is set to "" (blank)
attached is the project, if someone wants to test with it.
[attachment deleted by admin]