[CMake] A small philosophical problem

Philip Lowman philip at yhbt.com
Fri Jul 18 09:49:39 EDT 2008


On Fri, Jul 18, 2008 at 9:37 AM, Carminati Federico
<Federico.Carminati at cern.ch> wrote:

> Hello,
>    I want to be able to build optionally static libs for my project. I have
> no problem to add custom targets and dependencies, this all works nicely.
> However I want to be able to install them if needed. So I define an
> installation rule and I label it as optional, as these files may or may not
> exist. cmake complains with the following message
>
> WARNING: Target "TTherminator_a" has EXCLUDE_FROM_ALL set and will not be
> built by default but an install rule has been provided for it.  CMake does
> not define behavior for this case.
>
> I believe that this warning is justified if I do not lable the component as
> OPTIONAL, however if it is labelled as optional, the behaviour IS welll
> defined. The component is not there and it will not be installed. So I
> believe that in case of optional install targets the warning should not be
> there. BEst,


Is this not good enough for your needs?  We do something very similar at
work although we wrap all of the calls to ADD_LIBRARY and INSTALL with
macros.

ADD_LIBRARY(foo-shared SHARED foo.cc)
IF(BUILD_STATIC)
   ADD_LIBRARY(foo-static STATIC foo.cc)
ENDIF()

INSTALL(TARGETS foo-shared
   ARCHIVE DESTINATION lib
   LIBRARY DESTINATION lib
   RUNTIME DESTINATION bin)
IF(BUILD_STATIC)
   INSTALL(TARGETS foo-static
      ARCHIVE DESTINATION lib
      LIBRARY DESTINATION lib
      RUNTIME DESTINATION bin)
ENDIF()


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


More information about the CMake mailing list