Recent

Author Topic: Is there a way to conditionally add a package to a program?  (Read 4669 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Is there a way to conditionally add a package to a program?
« on: December 28, 2012, 09:41:42 pm »
Is there a way to conditionally add a package to a program?

I am writing a crossplatform program, for both Linux and Windows which uses a package that has only Windows related functions.

Is there a way to configure the package editor to make inclusion conditional or can I only use in ifdef in the lpr file?
Lazarus 3.0/FPC 3.2.2

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Is there a way to conditionally add a package to a program?
« Reply #1 on: December 28, 2012, 09:47:34 pm »
What package ? A visual component ?

Anyway, the package is in some unit. You can add directives {$IFDEF Windows} to uses list and to your code (where you create it). Then it will work only for Windows.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: Is there a way to conditionally add a package to a program?
« Reply #2 on: December 29, 2012, 01:53:42 am »
I am thinking more along the lines of the lpk file itself.

Do ifdefs apply to Pascal files only, ie *.lpr, *.pas, *.inc etc only?

What package ? A visual component ?

Anyway, the package is in some unit. You can add directives {$IFDEF Windows} to uses list and to your code (where you create it). Then it will work only for Windows.
Lazarus 3.0/FPC 3.2.2

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Is there a way to conditionally add a package to a program?
« Reply #3 on: September 15, 2014, 02:57:40 pm »
Sorry for reopening an old topic, but I'm in the same boat.  I only want my project to use the PilotLogic DSPack (directshow) if the operating system is Windows.  I've searched around in here, and found http://forum.lazarus.freepascal.org/index.php/topic,25341.msg153762.html#msg153762, from which I imply this cannot be done.

Am I right in assuming then, that my only way forward is to have two lpr's?  One for windows that uses the DSPack package, and one for everything else that doesn't?  This seems an odd way forward (but if needed, one I can live with)

(I'm happy enough that I can produce the conditional code that decides whether to include forms that rely on DSPack units or not, it's the Project Dependencies I'm trying to resolve)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Is there a way to conditionally add a package to a program?
« Reply #4 on: September 15, 2014, 03:09:19 pm »
remove the package from the required list and add the package's output directory to the applications search path since you have the ability to define multiple compilation templates (debug, release, win32, win64 etc) that each can have different path you can parameterize it from there if for any reason the application  requires access to the source code after adding the package output path to you project path option then you must remove the output path from before adding the source path otherwise the compiler will complain about  double files.

After that you need to make that the DSP components are dynamically created and of course you can use the designer/object inspector so have a workbench project that you can use the designer and object inspector to be able to find properties easier.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Is there a way to conditionally add a package to a program?
« Reply #5 on: September 15, 2014, 03:38:47 pm »
I see.   I can work with that, many thanks :-)

As for the dynamically created bit - I'm already only creating the controls in code, they're not on any forms (I always knew I was going to have to hide this code behind a define one day)
« Last Edit: September 15, 2014, 03:40:31 pm by Mike.Cornflake »
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Is there a way to conditionally add a package to a program?
« Reply #6 on: September 15, 2014, 10:33:21 pm »
Sorry for reopening an old topic, but I'm in the same boat. 
Don't worry about it. It's the way to go these days.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

 

TinyPortal © 2005-2018