[CMake] Determining a library name at configure time

Nils Gladitz nilsgladitz at gmail.com
Tue Sep 22 14:50:25 EDT 2015


On 09/18/2015 11:42 AM, Bill Newcomb wrote:
>> Suppose I add a library in my project:
>>
>> add_library(foo STATIC foo.c bar.c)
>>
>> Is there a way I can get the name of the generated library file at 
>> configure time?  LIBRARY_OUTPUT_NAME and OUTPUT_NAME for the target 
>> do not seem to be set:

Can you elaborate your use case?

If your use case allows for it you could delegate getting the file name 
to generation time (which is when the final file name is decided).
e.g. $<TARGET_FILE_NAME:target> [1] would expand to the file name 
(without path) of the given target  in the context of e.g. 
add_custom_command() commands.

Nils

[1] 
http://www.cmake.org/cmake/help/v3.3/manual/cmake-generator-expressions.7.html


More information about the CMake mailing list