Brady Dean
Brady Dean

Reputation: 3573

Generator expressions inside of target_link_libraries

I have this particular call to target_link_libraries that I am trying to get working.

target_link_libraries(
  Array
  $<$<CXX_COMPILER_ID:Clang>: c++abi>
  $<$<CXX_COMPILER_ID:GNU>: c++ c++abi c gcc_s gcc>
)

It is outputting a build command like this:

clang++ CMakeFiles/Array.dir/driver.cpp.o CMakeFiles/Array.dir/Array.cpp.o  -o Array $<1: -lc++abi> $<0: -lc++ -lc++abi -lc -lgcc_s -lgcc>

Am I writing the generator expressions correctly or is the call to target_link_libraries wrong?

Upvotes: 1

Views: 1720

Answers (1)

Brady Dean
Brady Dean

Reputation: 3573

So I fixed it my putting the the generators in quotes and replacing spaces with semi-colons.

target_link_libraries(
  Array
  "$<$<CXX_COMPILER_ID:Clang>:c++abi>"
  "$<$<CXX_COMPILER_ID:GNU>:c++;c++abi;c;gcc_s;gcc>"
)

Upvotes: 8

Related Questions