I'm trying to get the location of a static library of another project. I tried
get_property(target_name TARGET Test PROPERTY LOCATION) but CMAKE gives the following error
CMake Error at project.cmake:6 (get_property):
The LOCATION property may not be read from target "A".
Use the target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
I tried to use the generator expression mentioned in the error message with no success.
MESSAGE($<TARGET_FILE:A>)
just outputs the exact same string, so the generator expression doesn't seem to be evaluated at all:
$<TARGET_FILE:A>
I read the Documentation. In the first lines it mentions:
Generator expressions are evaluated during build system generation to produce information specific to each build configuration.
If I'm understanding this correctly then at the time the message function is evaluated the generator expressions are not evaluated anymore? So what am I supposed to be doing in this case?
I committed a minimal example of this problem on GitHub
EDIT:
I'm sorry to have asked the question in such a roundabout way without a clear explanation of my intentions:
My Aim is to get CMake to build a single (!) static library for my project, which someone else (who doesn't use CMake) can use. I would still use the "normal" resolution of dependencies for my project, but the other person - who doesn't use CMake - would have to manualy link multiple libraries to his project, which is somewhat inconvenient. A single library would solve this.
On my way of trying to get CMake to staticly link two static libraries, I read somewhere (sorry, I haven't saved a link) that at least when using Visual Studio as a compiler you can get the result I want if I append the full path of the static library to be linked to the static linker flags like that:
set_target_properties(B PROPERTIES STATIC_LIBRARY_FLAGS >>>INSERT_PATH_HERE<<<)
which does in fact work. But now I'd have to manualy insert the fully qualified path to the variable there
set_target_properties(B PROPERTIES STATIC_LIBRARY_FLAGS "/path/to/library.lib")
which doesn't seem to be a "good" way to do it to me. So I experimented with generator expressions and came up with the following one:
set_target_properties(B PROPERTIES STATIC_LIBRARY_FLAGS $<TARGET_FILE:A>)
which doesn't work, for reasons I don't fully understand. I guess set_target_properties just doesn't support generator expressions. While trying to get my project to work I tried
MESSAGE($<TARGET_FILE:A>)
(as stated above this explenation) and thought that if I'd get that statement to work I could solve my real problem. So thats what I asked the question posted above. I didn't realise that this would lead to confusion for the people trying to answer me.