Multiple targets in the same project

General questions regarding the usage of CodeLite
tankist02
CodeLite Veteran
Posts: 56
Joined: Thu Sep 22, 2011 11:29 pm
Genuine User: Yes
IDE Question: c++
Contact:

Multiple targets in the same project

Post by tankist02 »

Suppose I want to build both static and shared libraries from the same sources using one project. Those libraries would output into different directories. Everything else is the same - compiler flags, object files, etc. What would be the simplest way to achieve that?

Using "raw" makefiles it was easy - I just added an additional target (static lib) with its own command to link statically and place output into a different location. Now I need to do the same using Codelite build system.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Multiple targets in the same project

Post by eranif »

To create 2 different targets you need to define new build configuration. (codelite's build configuration is similar to a makefiles' target)

Assuming that you have one project A with one build configuration Debug_Dll and you want to create new configuration 'Debug_Static' which have the same settings as the 'Debug_Dll' configuration:

First you define new workspace configuration:

0) Open the configuration manager dialog from Build -> Configuration Manager
1) In the configuration Manager dialog, open the upper selection box (the one with the title 'Workspace Configuration') and select the option <New...>, in the dialog that comes up type the name of the workspace configuration (e.g. Debug_Static) and click OK

Next you define new project configuration:
0) Open the configuration manager dialog from Build -> Configuration Manager
1) Select the selection box at the top of the workspace view (the one which says 'Release' , 'Debug' etc) and select the option '<Open Configuration Manager..>'
2) In the dialog the comes up, Open the selection box of your project and select the option '<New...>'
3) In the 'New Configuration' dialog that pops up, type the name of the new configuration (i.e. Debug_Static) and select the build configuration that you want the settings to be copied from (i.e. Debug_Dll) and click 'OK'

Now all left to be done is to associate the workspace configuration with the project configuration:

0) Open the configuration manager dialog from Build -> Configuration Manager
1) In the upper selection box select the new workspace configuration 'Debug_Static'
2) Next, select the 'Debug_Static' for configuration for your project and click 'Apply'

Close and dismiss the configuration manager dialog.


Now, to switch 'targets' all you need to do is to select the desired configuration from the upper selection box.

Last thing to do is to change the project type from DLL to Static library:
Right click on your project and open the project settings dialog, on the first page, change the project type from 'Dynamic Library' to 'Static Library'.
Also remember to change the 'Output File'

You can read more here:
http://www.codelite.org/LiteEditor/ConfigurationManager

Eran
Make sure you have read the HOW TO POST thread
tankist02
CodeLite Veteran
Posts: 56
Joined: Thu Sep 22, 2011 11:29 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Multiple targets in the same project

Post by tankist02 »

Thank you very much for the detailed explanation.
Post Reply