[fpc-devel] Concerning compile options behavior

Sven Barth pascaldragon at googlemail.com
Sun Jan 29 10:59:09 CET 2012


On 29.01.2012 07:19, Gennadiy Poryev wrote:
> (Question 2)
> The same library source tree uses some subdirectories, so that each time I start a project using it, I have to manually include every subdir with its *.pas files into “-Fu” option, because the library sources are also being added and/or modified with each new project.  As the library grows, this is starting to be discomforting. May be I’m just not educated enough in the ways of FPC and missing some obvious functionality, but would it not be nice if we have “Add<x>  to unit path recursively” option (such as -Fx) ? That way I can only specify lib’s root directory and not care about how much subdirs it has.

There are three possibilities:

* If you reuse the units in the subdirectories often you can try to make 
Lazarus packages (see here: 
http://wiki.lazarus.freepascal.org/Lazarus_Packages ) out of them. Then 
you just add the package dependency to your project.

* Add the "-Fu" options to a custom cfg file (e.g. myfpc.cfg) and add 
this to FPC's command line using "@". The configuration will be used 
additionally to the default configuration.

E.g. fpc @myfpc.cfg myprogram.pas

* Use the "*" in the "-Fu" path. This will include all subdirectories in 
the given path and is e.g. used in the default FPC config file to 
include all package units besides "rtl"

E.g. fpc -Fu./* myprogram.pas

You need to pay attention though as your shell might handle "*" itself. 
On systems using bash, sh, zsh, etc. you'll need to use the following to 
have the correct value passed to FPC: fpc -Fu./\* myprogram.pas

Regards,
Sven





More information about the fpc-devel mailing list