DavidA
(David Aldrich)
1
Sorry this is a bit basic but how do I use a generator expression in target_sources, to conditionally add some source files?
Here is what I need to do:
option(extras "some help" "${extras_default}")
target_sources(${_lib_name}
PRIVATE
file1.cpp
<if extras> file2.cpp
)
fenrir
(Jakub Zakrzewski)
2
There is no need for generator expressions here. The simplest solution would be:
target_sources(${_lib_name}
PRIVATE
file1.cpp
)
if(extras)
target_sources(${_lib_name} PRIVATE file2.cpp)
endif()
DavidA
(David Aldrich)
3
Thank you, I didn’t realise that multiple target_sources commands are allowed.