0

I am using CodeLite for C++ development. I can edit AVAILABLE options under Settings/Build settings/Compiler Options or /Linker Options. I can also change the options of a PARTICULAR project under Workspace/Open Active Project Settings...

What I want to do is to change the default settings for ALL projects (or at least for all NEW projects). In the active project settings the first field is "Use with Global Settings" what implies that somewhere there should be access to these Global Settings, but I do not find. I only found under Build Settings/Advanced the Include Path and the Libraries Path but I do want to make other defaults as well, e.g. for the compiler "C++ Compiler Options" like e.g. .std=c++17 and for the linker "Linker Options" e.g. -pthread and "Libraries".

I make many little projects and it is a nightmare to change all these manually for every little project.

jollytall
  • 117
  • 8

1 Answers1

0

There is no UI to do this, but this can be done.

To apply a new compiler / linker options to your entire workspace, the easiest way to do this is:

  • Right click on your workspace icon
  • There are 2 tabs in this view, select the one that says Environment
  • To add some new compiler options, set the environment variable CXXFLAGS
  • To add a new linker options, set the environment variable LinkerOptions

For example, in order to compiler all my sources with -std=c++17 and link the binary with -s (strip) linker option, add the following to the environment variable section of the workspace:

CXXFLAGS=-std=c++17 $(CXXFLAGS)
LinkOptions=$(LinkOptions) -s

the CXXFLAGS is only applied to C++ source files e.g. *.cpp or other common extensions like *.cxx, *.cc etc. To set compiler options for C source files, use the environment variable CFLAGS

Notice that I am also concatenating the previous value, this makes sure that the new value does not override the old value, but adds to it

Eran
  • 2,310
  • 1
  • 13
  • 13
  • Thanks. although I could not do what you wrote, it led me to a good-enough solution and to more questions: 1. What/where is the workspace icon? If it is not in the UI, how can it have tabs? 2. I found in codelite Settings/Environment Variables a place where I can enter CXXFLAGS= and LinkOptions= and it works. Great! 3. $(CXXFLAGS) does not work here (recursive error). 4. I also found Active Project Settings/Global Settings what adds to the individual settings, however they are not global (do not appear in other projects what is entered here). – jollytall Jul 02 '21 at 07:35
  • 5. When a new project is started Include path has a . in it both under Compiler options and Global settings. Thus when a project is compiled -I. appears twice. 6. The step under point 2. can ADD new options, but cannot be used to remove default options (in my case I see for C++ compiler -O2;-Wall). If I do not want it, it has to be deleted manually for every new project. 7. Just as information for others, the variables have to be different than how they appear in the options: E.g. include path ../include has to be added as -I../include, library libone.so;libtwo.so becomes -lone -ltwo – jollytall Jul 02 '21 at 07:41