Options for different Platform Builds lazarus / 11-Options ---------------------------------------------------------------------- JimKueneman · 2012-12-06 05:00 I have unsuccessfully been trying to do a couple of thing with Lazarus: 1) Options:  I have this in Options[dialog]>Compiler Options>Other>Custom Options Text box: -dUseCThreads -k-macosx_version_min -k10.5 -XR/Developer/SDKs/MacOSX10.5.sdk/'' this is fine for OS-X but the last two give Ubuntu grief with the OS-X specific lines.  How can I create these options for the two compilers?  I have tried IFDEF in this text box but it does not seem to like that. 2) How can I create different directories for the compiled output to be put in for different OS builds?  Again the OS-X and Ubuntu step on each other and I would like a directory for Linux, OS-X, Win32 and Win64. Thanks Jim ---------------------------------------------------------------------- BigChimp · 2012-12-06 07:42 1) Don't know if there is a more elegant solution but you could see if different build modes work - they apply to a lot of the screens in Project options (e.g. linking) and may well also apply to the options screen. Then you 'd create a Ubuntu mode, OSX mode etc. Perhaps there is a better way, perhaps something with macros but haven't fiddled too much with that. 2) Classic example: see http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames the section IDE Macro Format for a solution: $(TargetCPU)-$(TargetOS) You must be crosscompiling for the output to step on each other's toes, right? Or are you passing along the entire project directory between images or computers to compile it, adding executables as you go along? ---------------------------------------------------------------------- JimKueneman · 2012-12-06 09:25 QuoteYou must be crosscompiling for the output to step on each other's toes, right? Or are you passing along the entire project directory between images or computers to compile it, adding executables as you go along? Yes that is what I a doing.  I just have a shared code base.  I just open Lazarus in each OS, open the *.lpi file and compile.  Because the OS-X compile puts the executable at the same level as the *.app file the Linux build uses the same file for its build. If I did a release build so OS-X would put the executable in the *.app folder this would not be an issue.  This is an open source/project so I am hoping to get the builds into separate folders so users can just go grab the latest executable from SVN as I check things in, without me needing to think about things like this.  They just happen automagicallly. Jim Update:   yes if you do this in the Options>Target File Name (-o) edit box: apps\$(TargetCPU)-$(TargetOS)\AppName You get a nice separation of compiled outputs in their own clearly identified folders. Thanks.  Now to work the first issue. ---------------------------------------------------------------------- Leledumbo · 2012-12-06 13:31 QuoteI have tried IFDEF in this text box but it does not seem to like that.The options here are passed directly to the compiler, so you can't do ifdef here. You can make separate build mode for each target you want to support. QuoteHow can I create different directories for the compiled output to be put in for different OS builds?I personally use bin/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType) ---------------------------------------------------------------------- JimKueneman · 2012-12-06 14:38 QuoteThe options here are passed directly to the compiler, so you can't do ifdef here. You can make separate build mode for each target you want to support. I am not quite sure what you mean here but this is what I am trying (since I really don't understand what I am doing I am stumbling here) Options>Compiler Options>IDE Macros Created a new Macro "MyMacro" with this in the text, note I did not create any "sub" items under this. Code: [Select]if TargetOS = 'darwin' then begin   CustomOption += ' -k-macosx_version_min -k10.5';   CustomOption += ' -XR/Developer/SDKs/MacOSX10.5.sdk/'; end; if SrcOS = 'unix' then   CustomOption += ' -dUseCThreads;'  Which says it has not errors.  So now how do I use it?  I went to Options>Compiler Options>Build Modes I only have 1, the default.  So I selected "MyMacro" from the Macro Name pull down.  But when I run the "test" none of my custom option are added to the OS-X command line.  There is a place for a "value" of the macro but I don't have any user variables mine are all built in OS things It seems like I should be close...... Jim ---------------------------------------------------------------------- Leledumbo · 2012-12-06 14:50 QuoteI am not quite sure what you mean hereMaybe you should read this ---------------------------------------------------------------------- Martin_fr · 2012-12-06 15:11 Actually a bit further down the page http://wiki.lazarus.freepascal.or g/IDE_Window:_Compiler_Options#IDE_Macros Also has a link to this http://wiki.lazarus.freepascal.org/Macros_and_Conditionals#Adding_some _linker_options_for_target_Mac_OS_X ---------------------------------------------------------------------- JimKueneman · 2012-12-08 18:43 Thanks everyone, I knew I as close.  Created a new IDE Macro and added this in the conditionals.  Works like a charm.  It is easy once you get the names of the built in variables correct  Code: [Select]if TargetOS = 'darwin' then begin   CustomOptions += '-k-macosx_version_min -k10.5';   CustomOptions += '-XR/Developer/SDKs/MacOSX10.5.sdk/';   CustomOptions += ' -dUseCThreads'; end; if TargetOS = 'linux' then   CustomOptions += ' -dUseCThreads'; Notice the "s" on the end of CustomOptions.  That what I was overlooking Quote from: Martin_fr on December 06, 2012, 04:11:06 pmActually a bit further down the page http://wiki.lazarus.freepascal.org/IDE_Window:_C ompiler_Options#IDE_Macros Also has a link to this http://wiki.lazarus.freepascal.org/Macros_and_Conditionals#Adding_some _linker_options_for_target_Mac_OS_X ---------------------------------------------------------------------- Fred vS · 2012-12-09 02:25 @ JimKueneman . many thanks for your tip: Like you have borrowing things to do with Linux and OsX . For Linux it is a "must": Quoteif TargetOS = 'linux' then   CustomOptions += ' -dUseCThreads'; And for Older OsX version (i use 4.0) . Quoteif TargetOS = 'darwin' then begin   CustomOptions += '-k-macosx_version_min -k10.4';   CustomOptions += '-XR/Developer/SDKs/MacOSX10.4u.sdk/';   CustomOptions += ' -dUseCThreads'; end; Now, i do not have to change in Options[dialog]>Compiler Options>Other>Custom Options everytime i change OS. Many thanks. ---------------------------------------------------------------------- JimKueneman · 2012-12-09 15:05 Quote from: Fred vS on December 09, 2012, 03:25:35 amAnd for Older OsX version (i use 4.0) . Quoteif TargetOS = 'darwin' then begin   CustomOptions += '-k-macosx_version_min -k10.4';   CustomOptions += '-XR/Developer/SDKs/MacOSX10.4u.sdk/';   CustomOptions += ' -dUseCThreads'; end; Now, i do not have to change in Options[dialog]>Compiler Options>Other>Custom Options everytime i change OS. Many thanks. That was what I was getting sick of doing as well. Where can I get the SDK for Tiger?  I would like to support as far back in OS X as possible.  I have only been able to find the SDK for Leopard on the Apple Developers site. Jim ---------------------------------------------------------------------- Fred vS · 2012-12-09 15:15 http://lazarus.freepascal.org/index.php/topic,12182.msg62134.html#msg6 2134 ---------------------------------------------------------------------- JimKueneman · 2012-12-09 16:16 I just opened up XCode 3.2 with Pacifist.   There are 3 SDKs in there: MacOSX10.6.pkg MacOSX10.5.pkg MacOSX10.4u.pkg I am assuming the "u" = "Universal" is the SDK that works with the PowerPC and the Intel.  I have no way to test on Tiger (nor do I know anyone who can try it).  Thanks, Jim Update: Successfully compiled with 10.4u.   Thanks!