[CMake] Getting library name from library target to pass to legacy Makefile

Dustyn Blasig dustyn at blasig.us
Sun Jul 21 23:23:56 EDT 2019


Hi All,

I am integrating a legacy Makefile with our CMake flow, and need to pass
the name of a CMake library target to the Makefile via
add_custom_command(). The library uses the OUTPUT_NAME property to override
the default.

add_library(foo_lib SHARED ...)
set_target_properties(foo_lib PROPERTIES OUTPUT_NAME foo) # Generates
libfoo.so
add_custom_command(... COMMAND make ... FOO_LIB_LINKER_NAME=<????> ...)

I need <????> to be the value passed to -l of g++, namely -lfoo or -lfood
for debug builds. I can't seem to find an expression/property that gives
this shortened name. The generator expressions like TARGET_LINKER_FILE_NAME
give libfoo.so.

What is the appropriate way to get just the stem of the library with the
configuration-specific suffix if needed?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190721/fdd47ac7/attachment.html>


More information about the CMake mailing list