<div class="gmail_quote">2009/7/4 Aurélien Vallée <span dir="ltr">&lt;<a href="mailto:vallee.aurelien@gmail.com">vallee.aurelien@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<div><br></div><div>I have some questions regarding CMake generator for VS9.</div><div><br></div><div>My library can be built as shared or static. Currently, this is handled using two different targets in CMakeLists.txt.</div>

<div>The problem is that under Visual Studio 2008, those two targets are two projects !</div><div><br></div><div>So in the solution explorer I have something like :</div><div><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">

* MyLibrary_Solution</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
    * Module1_static</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
    * Module1_dynamic</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
    * Module2_static</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
    * Module2_dynamic</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
  ...</blockquote><div><br></div><div>This is really annoying, since the source files are the same, only the configuration changes (defines ...).</div><div><br></div><div>I wondered whether it would be possible to have those different targets become different configurations.</div>
</blockquote><div><br>Not at present, no.  It would be a neat feature to have but probably challenging to implement.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Here is my CMakeLists.txt for a module (Windowing) :</div><div></div></blockquote><div><br>One thing you could do is use macros which operate on &quot;static&quot; and/or
&quot;dynamic&quot; targets to make your code roughly half as long.  You can use the
IF(TARGET...) argument.<br>
<br>
MACRO(SET_BOTH_TARGET_PROPERTIES _target)<br>
   IF(TARGET ${_target}_dynamic)<br>
      SET_TARGET_PROPERTIES(${_target}_dynamic ${ARGN})<br>
   ENDIF()<br>
   IF(TARGET ${_target}_static)<br>
      SET_TARGET_PROPERTIES(${_target}_static ${ARGN})<br>
   ENDIF()<br>
ENDMACRO()<br><br>then simply call it once...<br><br>SET_BOTH_TARGET_PROPERTIES(Windowing PROPERTIES DEBUG_POSTFIX &quot;d&quot;)<br>
<br></div></div>-- <br>Philip Lowman<br>