* * *

Author Topic: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.  (Read 199 times)

ChrisR

  • New member
  • *
  • Posts: 13
Hello-
  Is there  a way to have the IDE compile to Cocoa (instead of Cocoa) when compiling on MacOS (Darwin) OS but compile to the default widgetset (Linux->GTK2; Windows->WinAPI) on other OSes? Effectively, I would like the IDE to do what I can do in the command line with the following script:

if [[ "$OSTYPE" == "darwin"* ]]; then
    echo "macOS compiling for Cocoa, instead of default Carbon widgetset"
    lazbuild  -B --ws=cocoa ./simplelaz.lpr
else
    lazbuild -B ./simplelaz.lpi
fi


1.) I realize I set Additions&Overides to "LCLWidgetType:=cocoa", which works on MacOS (Darwin), but fails on other OSes.

2.) This old page suggests there is a  "-dCarbonUseCocoa", but this seems to be for building the IDE, and adding it as a "Custom Option" for a project has no impact.
http://wiki.freepascal.org/Carbon_Interface

3.)  I know I can go to "Custom Options" and set the conditional
        CustomOptions += ' -dLCLCocoa';     
But the "Show Option" button then lists BOTH options "-dLCLcarbon -dLCLCocoa" and the project is compiled to Carbon.

Phil

  • Hero Member
  • *****
  • Posts: 1885
Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
« Reply #1 on: January 09, 2017, 09:52:10 pm »
  Is there  a way to have the IDE compile to Cocoa (instead of Cocoa) when compiling on MacOS (Darwin) OS but compile to the default widgetset (Linux->GTK2; Windows->WinAPI) on other OSes?

I think the idea is that you would use a build mode for that and select that mode when you compile instead of the default mode. Note that you can specify the build mode with lazbuild too.

I'll admit I haven't used this feature since I don't use Lazarus IDE much and it looks a bit complicated in the IDE, so probably a thorough reading of the help will be needed:

http://wiki.lazarus.freepascal.org/IDE_Window:__Compiler_Options#Build_modes

ChrisR

  • New member
  • *
  • Posts: 13
Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
« Reply #2 on: January 09, 2017, 10:40:39 pm »
Thanks, yes I can make a build mode that supports macOS, but that build mode will not be automatically used when I compile on macOS and automatically disabled on other systems. This means I need to always configure the build mode for each operating system. It is also confusing for new users who download my projects from Github, as it does not "just work" out of the box. The issue for me is that my projects use OpenGL 3.3 which requires Cocoa (Carbon is limited to Legacy OpenGL 2.1).

Phil

  • Hero Member
  • *****
  • Posts: 1885
Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
« Reply #3 on: January 09, 2017, 10:50:59 pm »
Thanks, yes I can make a build mode that supports macOS, but that build mode will not be automatically used when I compile on macOS and automatically disabled on other systems.

I guess that's just the nature of build modes. All IDEs have them in some form or another, typically with Debug and Release as the standard choices by default.

Perhaps you could include a little .txt file in your project as the default file shown in the IDE. Here give the one or two sentence instructions for building on Mac. Not ideal, but that would probably get the job done if you're concerned about confusing users.


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus