[CMake] Can I determine what a target is in a macro?

Stephen Kelly steveire at gmail.com
Tue Jul 12 19:23:23 EDT 2011


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.



More information about the CMake mailing list