When is the TARGET_NAME generator expression necessary?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

When is the TARGET_NAME generator expression necessary?

CMake mailing list
Hello,

I was reading the CMake documentation regarding generator expressions, and I found the following:

"$<TARGET_NAME:...>
Marks ... as being the name of a target. This is required if exporting targets to multiple dependent export sets. The ... must be a literal name of a target- it may not contain generator expressions."

From that I understand that if some targets from an export set depend on other targets from other export set, the dependencies should be specified using $<TARGET_NAME:...> instead of the targets' names.
I found the thread (this message specifically: https://www.mail-archive.com/cmake-developers@.../msg05498.html) that is responsible for the introduction of the TARGET_NAME generator expression, however I cannot find an example for its use.

I believe it has something to do with adding the correct namespace to the "required library".

I tried an example of dependent export sets in which I do not use $<TARGET_NAME:...>, I even use the target's name inside another generator expression, but no error is generated and the output files contain the correct "imported" targets (with the correct namespaces):

"project(target_name)
add_library(a a.cpp)
add_library(b b.cpp)

target_link_libraries(b $<$<EQUAL:1,1>:a>)


export(TARGETS
       a
       NAMESPACE foo_
       FILE a_config.cmake
)
 
export(TARGETS
       b
       NAMESPACE bar_
       FILE b_config.cmake
)"

When are we required to use the TARGET_NAME generator expression?


Thank you,
Razvan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake