title: Will a "rebuild as needed" library be recompiled if I change settings of a project that uses it?
body: <p>I have a program that uses a library (DPK/visual controls). The library was compiled in Debug mode. Which means that Optimizations is OFF, RangeChecking is ON, etc, etc. The library is set to 'Rebuild as needed'. I do not intend to redistribute it (internal use only).</p>
  
  <p>What happens if I compile my program in 'Release' mode? The code contained in the library will be recompiled automatically to 'Release' mode? Or I have to load the DPK and recompile my library in 'Release' mode first?</p>
  
  <hr>
  
  <p>Update:<br>
  Related to 'Rebuild as needed' Embarcadero's help says it all: "Builds the package as needed".
  Which I interpret as 'if the program is compiled in Release mode, the library needs to be recompiled so we will do it for you'.
  Is my interpretation too... biblical?</p>
  
  <hr>
  
  <p>This experiment shows that (in the conditions described above) the code contained in a library will be compiled into the EXE based on DPR's settings and not on DPK's settings.</p>
  
  <p>The compiler does not care about DPK file when it recompiles its PAS files (applies only when the DPK in not loaded in IDE).**</p>
  
  <p>So here is the (easy to reproduce in all systems) proof:
  Let's call my program Prog.DPR (contains Prog.pas) and my library Lib.DPK (contains LibUnit.pas). The library contains TMyPanel visual control. DPR is in Release mode. DPK is in debug mode.</p>
  
  <pre><code>I install the library. I exit the library ('Close all').
  I load the DPR in IDE, I also load LibUnit (Attention: I load only the unit, not the DPK)
  I put TMyPanel on my program's form.
  The LibUnit is automatically added to the USES clause on my program.
  I edit LibUnit. I compile. It works. New DCU file is generated for LibUnit.
  I go to library's folder and I delete the DPK (and the Dproj) but I keep LibUnit.pas.
  I edit LibUnit. I compile. Still works! New DCU file is generated for DCU file is generated for LibUnit.!!!!
  </code></pre>
  
  <p>The question is: if there is no info about how LibUnit should be compiled (the PDK was deleted), how was LibUnit compiled????? Obviously the compiler used DPR's settings. Which is 'Release' mode. Which means my library was integrated into the program as 'release'. .</p>