[CMake] Static/Shared library targets becomes Static/Shared configurations under VS9

Philip Lowman philip at yhbt.com
Sat Jul 4 23:07:34 EDT 2009


2009/7/4 Aurélien Vallée <vallee.aurelien at gmail.com>

> Hello,
> I have some questions regarding CMake generator for VS9.
>
> My library can be built as shared or static. Currently, this is handled
> using two different targets in CMakeLists.txt.
> The problem is that under Visual Studio 2008, those two targets are two
> projects !
>
> So in the solution explorer I have something like :
>
> * MyLibrary_Solution
>
>     * Module1_static
>
>     * Module1_dynamic
>
>     * Module2_static
>
>     * Module2_dynamic
>
>   ...
>
>
> This is really annoying, since the source files are the same, only the
> configuration changes (defines ...).
>
> I wondered whether it would be possible to have those different targets
> become different configurations.
>

Not at present, no.  It would be a neat feature to have but probably
challenging to implement.

Here is my CMakeLists.txt for a module (Windowing) :
>

One thing you could do is use macros which operate on "static" and/or
"dynamic" targets to make your code roughly half as long.  You can use the
IF(TARGET...) argument.

MACRO(SET_BOTH_TARGET_PROPERTIES _target)
   IF(TARGET ${_target}_dynamic)
      SET_TARGET_PROPERTIES(${_target}_dynamic ${ARGN})
   ENDIF()
   IF(TARGET ${_target}_static)
      SET_TARGET_PROPERTIES(${_target}_static ${ARGN})
   ENDIF()
ENDMACRO()

then simply call it once...

SET_BOTH_TARGET_PROPERTIES(Windowing PROPERTIES DEBUG_POSTFIX "d")

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090704/ae826bc6/attachment.htm>


More information about the CMake mailing list