[CMake] Can I determine what a target is in a macro?
David Cole
david.cole at kitware.com
Tue Jul 12 20:53:54 EDT 2011
The target property TYPE tells you what the type of the library is:
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:TYPE
Use:
get_property(type TARGET ${SOME_TARGET} PROPERTY TYPE)
message("type='${type}'")
to retrieve the value of the TYPE property.
http://cmake.org/cmake/help/cmake-2-8-docs.html#command:get_property
HTH,
David
On Tue, Jul 12, 2011 at 7:23 PM, Stephen Kelly <steveire at gmail.com> wrote:
>
> Hi,
>
> I'd like to be able to write a macro like this:
>
> macro(my_macro SOME_TARGET)
> if (isStaticLibraryTarget(${SOME_TARGET})
> message(FATAL "This macro can only be used with shared libraries")
> endif()
> endmacro()
>
> add_library(libshared SHARED shared.cpp)
> my_macro(libshared) # Works
> add_library(libstatic static.cpp)
> my_macro(libstatic) # Fatal
>
> Is it possible to whether a target library is shared or static in a macro?
>
> Thanks,
>
> Steve.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list