Recent

Author Topic: "Set compiler options as default" does NOT save custom paths  (Read 4759 times)

lazaruser

  • Newbie
  • Posts: 5
"Set compiler options as default" does NOT save custom paths
« on: April 12, 2021, 01:51:24 am »
Hi.
Please, does anyone know, how to you make the compiler options Paths stay the way I set them up for all new created projects?

What I tried is:
1. Open Lazarus, create and save new empty project.
2. Set up my own Project options > Compiler options > Paths > Unit output directory and Target file name.
3. Checked Set compiler options as default.
4. Saved and closed the project.

Alas, after creating another empty project, although at first it seems my custom paths are visible in the Project options, once I save that project, the paths revert to the "factory" defaults.

It's weird because other options, ie. Compilation and Linking or Debugging, are all preserved, just the Paths are resetting.

Please, advise.
« Last Edit: April 13, 2021, 04:53:08 pm by lazaruser »

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Custom Paths in Compiler options reset when project saved
« Reply #1 on: April 12, 2021, 04:46:25 am »
What version of Lazarus, FPC and OS?
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

lazaruser

  • Newbie
  • Posts: 5
Re: Custom Paths in Compiler options reset when project saved
« Reply #2 on: April 12, 2021, 06:47:59 am »
Hi.
Thank you for response. And sorry, I should've write that in the first place.

I've downloaded the installer yesterday and I'm currently using
Lazarus 2.0.12 fpc 3.2.0 SVN revision 64642 x86_64-win64-win32/win64

After a clean install I've only changed language to English and added 1 package (AnchorDockingDsgn 1.0).

My OS is Windows 7 x64 SP1.

I've checked yet again and confirmed: if I change the Paths ie.
Unit output directory to lib\$(TargetCPU)-$(TargetOS)
and Target file name to release\$(TargetOS)-$(TargetCPU)\$NameOnly($(ProjFile))
in the Project options > Compiler options the values are stored properly until the moment I save the project.
Then when I re-open the options my paths are gone ie.
Unit output directory reverts to lib\$(TargetOS)-$(TargetCPU)
and Target file name to literal project1.

Cheers.

Ps. I'm sory, mods, for a double post (same message in the other thread). Won't happen again.

« Last Edit: April 12, 2021, 07:06:06 am by lazaruser »

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Custom Paths in Compiler options reset once project is saved
« Reply #3 on: April 12, 2021, 12:04:59 pm »
Normally there is no need to change the paths in the Lazarus settings. In this respect, Lazarus is fundamentally different from Delphi. When a new component is added to Delphi the unit path is extended by the path to the new component so that this path gets longer and longer. In Lazarus, you work with packages: when you need a unit of some package you add the package to the requirements of the project ("Project" > "Project inspector" > "Add" > "New requirement" > select the package from the dialog). The IDE takes care of finding the related units without extending the overall unit path.

Extending the unit path will result in a variety of severe compilation issues. Don't do this. This is only needed for the within-project paths when a project distributes its units over several directories. Delete the ppu output directory of your project and recompile it.

lazaruser

  • Newbie
  • Posts: 5
Re: Custom Paths in Compiler options reset once project is saved
« Reply #4 on: April 12, 2021, 07:05:00 pm »
Hi.
I understand, but then if I want to compile to many different targets at once (Compile many Modes), I have to do it one by one and manually rename/move the executable, otherwise it gets overwritten.
I found a nice tutorial the other day explaining how to add many build modes and seemingly easily cross compile (link: youtube.com/watch?v=qOzreCx2xWA ) a single project to many targets.
I gues that procedure is no longer valid. The documentation to the IDE is lacking, to say the least, so it's double dissapointing that instructions like these can get obsolete so fast.

Then again, I just found out that cross compiling with Lazurus in general isn't as straight forward as one might think. Apparently if you're using Windows you can't just add many build modes for different target architectures/OSes and expect a single Lazarus installation to built all the different executables.

Regardless, if the IDE offers me options to modify I expect it to respect my choices and not just cancel them without reason.

Also it's inconsistent that you can have Unit output directory go to lib\$(TargetOS)-$(TargetCPU), but not with the executables.

Also that's not entirely true, because as I said, unless I save the project my setting for Target file name (and the other one) will work as intended.
IMO, at this point this behavior has to be considered a bug and if these options are so volatile they have to be forcibly kept a certain way they shouldn't be exposed to the user IMO and the documentation/help should explicitly warn about changing them.

Cheers.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Custom Paths in Compiler options reset once project is saved
« Reply #5 on: April 12, 2021, 10:05:15 pm »
Just tested one of my applications with this in the "Target File Name (-o)" box:
Quote
../bin/$(TargetOS)-$(TargetCPU)/$NameOnly($(ProjFile))
and it worked correctly.

Are you aware that the Compiler Options are per build-mode? So when you set the target file name in one build-mode and switch build to another build mode then the settings change according to what has been set up for this other build mode. Not 100% sure but I think that these settings must be defined before build modes are created so that they can propagate to the individual build modes.

lazaruser

  • Newbie
  • Posts: 5
Re: "Set compiler options as default" does NOT save custom paths
« Reply #6 on: April 13, 2021, 05:09:48 pm »
Hi.
Yes, I'm aware of that. Thank you.

I changed the title, perhaps I wasn't clear enough what I've found is wrong.

I reiterate. I want to have my own custom Compiler options be already set for all new (empty) projects I create in the future, and I'm doing it like that:
1. create empty project
2. set up Compiler options, add release Build modes, set target OS, disable debugging etc.
3. check Set compiler options as default
4. save and close everything

Then I re-open Lazarus and create another empty project, check its Compiler options and POOF! my custom paths are gone, BUT all the other settings (OS, debugging) are there! Only paths are missing/reset to "factory" defaults.

If you create a project and set it up and save, then for that project everything is preserved, but I don't want to do that every time I create a project and my understanding is "Set compiler options as default" is the very thing I need to check to achieve my goal, but it doesn't fully work. That's my problem.

Cheers.
« Last Edit: April 13, 2021, 05:43:54 pm by lazaruser »

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: "Set compiler options as default" does NOT save custom paths
« Reply #7 on: April 13, 2021, 05:44:56 pm »
Since you are a Windows user (like me) I strongly advise against touching the "Set compiler options as default" checkbox. It does not differentiate between GUI and non-GUI projects and uses the same "Target-specific options - Win32 gui application (-WG)" setting in "Config and Target" for all types of projects. Having this checked when you activated the "Set compiler options as default" a commandline program will not be to WriteLn to the console any more ("File not open" error). It took me fairly long until I found this self-made issue.

Bart

  • Hero Member
  • *****
  • Posts: 5274
    • Bart en Mariska's Webstek
Re: "Set compiler options as default" does NOT save custom paths
« Reply #8 on: April 13, 2021, 05:51:39 pm »
Contrary to wp: I do have and use default compiler options.
However, my default compiler options have a debug and release mode.
In debug mode (my default mode) I have the "Windows GUI" option disabled.

B.t.w. I file a feature request in the bugtracker to have default compiler options per application type (so differentiate between simple console and GUI).

Bart

 

TinyPortal © 2005-2018