[CMake] Passing generator expressions in variables

Auer, Jens jens.auer at cgi.com
Thu Jul 30 03:14:46 EDT 2015


Hi,

I am trying to dynamically assemble a list of generator expressions and use them in add_executable. The background is that I have some macros to add targets, e.g.
add_my_library(TARGET liba SOURCES ...) # this class add_library(liba OBJECT ...) internally
add_my_executable(TARGET a DEPENDS liba libb SOURCES ...)

In add_my_executable, I create a list of $<TARGET_OBEJCTS:${d}> strings for all d {liba, libb}. However, cmake complains that it cannot find the source file $<TARGET_OBJECTS:liba>.

A simplified example of what I want to do is this:
add_library(A OBJECT a.cpp)
set(alib $<TARGET_OBJECTS:A)
add_executable(a.exe ${alib})
add_executable(b.exe $<TARGET_OBJECTS:A> )

With cmake 3.2.2, the first add_executable fails, the second one works. Is there another way to do this?

Best wishes,
  Jens

--
Dr. Jens Auer | CGI | Software Engineer
CGI Deutschland Ltd. & Co. KG
Rheinstraße 95 | 64295 Darmstadt | Germany
T: +49 6151 36860 154
jens.auer at cgi.com<mailto:jens.auer at cgi.com>
Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben<http://de.cgi.com/pflichtangaben>.

CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150730/e81b50fb/attachment-0001.html>


More information about the CMake mailing list