Recent

Author Topic: MacOS specific packages  (Read 2573 times)

ChrisR

  • Full Member
  • ***
  • Posts: 247
MacOS specific packages
« on: August 22, 2018, 04:19:13 pm »
Hello,
  Is there anyway to have a Lazarus project automatically include/exclude a package depending on the OS it is running on?

  As a concrete example, consider my projects that use Ryan Joseph's lazmetalcontrol for Metal graphics on MacOS, but these same projects use LazOpenGLContext for graphics on Linux and Windows:
    https://github.com/neurolabusc/Metal-Demos
At the moment, the user needs to open the Project Inspector and remove the "lazmetalcontrol" from the Required Packages in order to compile on Linux or Windows.
  I use IFDEFs in the main code to select between these two options, but I have not found a way to specify OS-specific packages.

Another example where this would be useful is Dmitry's
  http://wiki.freepascal.org/macOS_extensions
This package can provide Mac-specific features but is necessarily MacOS specific. Again, it would be nice to include this package when compiling for MacOS and exclude when compiling for Windows and Linux.


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: MacOS specific packages
« Reply #1 on: August 22, 2018, 04:30:00 pm »
This package can provide Mac-specific features but is necessarily MacOS specific. Again, it would be nice to include this package when compiling for MacOS and exclude when compiling for Windows and Linux.
The package won't do anything in runtime except on Cocoa.
So, there's no need to exclude the package for any other widgetset.

The intent of MacOS Extension is to allow an application to be a bit more macOS native.
Yet, remaining cross platform for any other place.

ChrisR

  • Full Member
  • ***
  • Posts: 247
Re: MacOS specific packages
« Reply #2 on: August 22, 2018, 04:41:10 pm »
I agree: the Metal and MacOS packages have no purpose outside of MacOS. However, when we create a Lazarus project we must include them as requirements in the Project Inspector. The pascal source code can selectively choose these based on {$IFDEF Darwin}, but the project will not compile on Linux or Windows unless the user manually removes the package requirement in the Project Inspector.

What I would like is a way for a project to automatically require the Mac specific packages when run on a Mac but not require them when run on a Linux or Windows. This would let developers seamlessly build my projects regardless of their OS.

 

TinyPortal © 2005-2018