0

I am using CodeLite (version 11.0.0) on Ubuntu 16.04 to develop a static library.

I configured the Debug mode to produce an executable and I made a main.cpp file to call functions in my library and test them.

The goal of the project is however to produce a static library. I have already asked how to make a static library, and I'm now aware of how to do that. The problem is, the solution I was proposed involved having a separate project for making the library.

This comes with annoyances, as I am developing source files in one project, and would need to make use of them in another one. After a couple of tedious copy-paste-and-debug exercises, I tried to set a Release mode to produce a static library out of the same source files.

The problem though is that I don't know how to tell CodeLite to build main.cpp in Debug, but ignore it in Release.

Debug folder should be:

main.cpp
module1.h
module1.cpp
module2.h
module2.cpp
library1.h

Release folder (to build a static library) should be:

module1.h
module1.cpp
module2.h
module2.cpp
library1.h

How do I tell CodeLite to use two different lists of source files when in different configurations? CodeLite stores this information in xml format inside a .project file:

<![CDATA[00020001N0005Debug0000000000000001N0007Release000000000000]]>
    </Plugin>
  </Plugins>
  <Description/>
  <Dependencies/>
  <VirtualDirectory Name="src">
    <File Name="main.cpp"/>
    <File Name="module1.h"/>
    <File Name="module1.cpp"/>
    <File Name="module2.h"/>
    <File Name="module2.cpp"/>
    <File Name="library1.h"/>
  </VirtualDirectory>

The same file also stores all dependancies. I thought of modifying it somehow, until I realised the file is automatically updated in the moment the configuration is changed from Debug to Release or vice versa.

Other thoughts I had were to somehow create a new project, or an entire workspace, in the same folder where all my files are held, and to have separate Git repositories or submodules in the same folder, using .gitignore smartly. However, they didn't seem neither elegant nor reliable solutions.

Is there a way I can have a single repository and project configurations in CodeLite to properly being able to both develop and test (running an executable called by main) and build a static library (excluding main) without needing to write and maintain CMake files?

raggot
  • 992
  • 15
  • 38
  • Why don't you link that static library into your test project instead of copypasting code? – user7860670 Nov 07 '17 at 14:49
  • @VTT That's what I am trying to do, but building an executable (what I do with testing) is not the same as building a library. What do you mean exactly? – raggot Nov 07 '17 at 14:51
  • I mean that you need two (2) projects, one is static library with relevant code and another one - test executable that links static library from first project. You may also want to add third - "example" - project demonstrating typical use of your static library. – user7860670 Nov 07 '17 at 14:57
  • @VTT, now I follow. Basically it's what I mentioned in the second-last paragraph, but without needing 2 repositories. I'll give it a try – raggot Nov 07 '17 at 15:10
  • @VTT, it worked. There was no need of copy-pasting, and I now realise that was supposed to be done like this since the beginning... Thank you – raggot Nov 07 '17 at 15:30

0 Answers0