title: Some C++ source files are compiled for multiple dll
body: <p>In our projects my team wants to use some C++ source files for different dlls (for example MySource.cpp, amongst others, will be compiled twice to produce both A.dll and B.dll). I'll call this situation "duplicating compilations". I think it is very bad practice and I see mainly 2 reasons:</p>
  
  <ul>
  <li>MySource.cpp must be able to support multiple compilers.</li>
  <li>All dependencies of MySource.cpp must be compiled in A.dll and B.dll.</li>
  </ul>
  
  <p>This imposes a lot of restrictions on the sources which will be compiled multiple times. Is there any other reasons why it shouldn't be done or why it is ok to do it ?</p>
  
  <p>This is how we came to this situation: we first created a module X, and then others modules Y, Z, etc... which are dependent on X. But instead of exporting X's functions to be used in Y, Z, we have duplicated the code of X so that the codes of Y and Z modules all contain a copy of the code of X. Then the code of X has evolved, and now we realize that we need to merge all those codes to have a real dependency. And now we are debating between the above "duct tape" solution and creating an API for X.</p>