Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: ChrisR on January 09, 2017, 08:27:55 pm

Title: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
Post by: ChrisR on January 09, 2017, 08:27:55 pm
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.
Title: Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
Post by: Phil 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
Title: Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
Post by: ChrisR 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).
Title: Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
Post by: Phil 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.

Title: Re: Have IDE use Cocoa for OSX but Default Widgetset for other OSes.
Post by: tk on January 24, 2017, 09:13:29 am
I also use another build mode for OS X because I need to specify another path for output executable. 

(I test on virtual OS X and all of my projects are always stored in a shared folder that comes from host computer. Because the linker cannot build final executable in this folder I have to specify another path for it.)

Just set the build mode name to OSX or similar and instruct users of your repository.
TinyPortal © 2005-2018