How can I get the basename of a target library with CMake?
I'm creating a library with the CMake variable name ${lib} as in
set(lib lib)
add_library(${lib} ...
I need the basename of the generated library file.
CMake will create a library with the filename <prefix>lib.<extension>
where both <prefix>
and <extension>
are platform specific.
I've tried the generator $<TARGET_FILE_NAME:${lib}>
which gives me the full name, which works because I'm needing this in a COMMAND, which is one of the few places where CMake allows generators.
To remove the extension using CMake I need to use GET_FILENAME_COMPONENT as in
GET_FILENAME_COMPONENT(<var> <filename> NAME_WE)
but this is used to set the variable <var>
(in normal CMake fashion) and generators don't work there.
(The CMake language is an irregular abomination, if you ask me. CMake, as a concept, is pretty cool.)