set_target_properties called with incorrect number of arguments

1.5k Views Asked by At

I'm trying to build prusaslicer dependencies over superslicer (is not related to the question) but I'm getting an error in the FindTBB.cmake file where it says that

set_target_properties called with incorrect number of arguments.

The following code is from where if complains about the format:

set_target_properties(TBB::tbb PROPERTIES
      INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS}"
      INTERFACE_LINK_LIBRARIES  "Threads::Threads;${CMAKE_DL_LIBS}"
      INTERFACE_INCLUDE_DIRECTORIES  ${TBB_INCLUDE_DIRS}
      IMPORTED_LOCATION              ${TBB_LIBRARIES})

What can I do to fix this?

1

There are 1 best solutions below

0
On

set_target_properties requires the value of the property to be exactly 1 parameter, so the TBB_INCLUDE_DIRS or TBB_LIBRARIES not containing exactly one element (which given the use of plural is likely) does break things. The values need to be quoted in order to ensure the snippet works regardless of the number of elements in those (list?) variables.

set_target_properties(TBB::tbb PROPERTIES
      INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS}"
      INTERFACE_LINK_LIBRARIES      "Threads::Threads;${CMAKE_DL_LIBS}"
      INTERFACE_INCLUDE_DIRECTORIES "${TBB_INCLUDE_DIRS}"
      IMPORTED_LOCATION             "${TBB_LIBRARIES}")

The alternative would be to use the set_property command instead, which does allow you to specify multiple values.

set_property(TARGET TBB::tbb PROPERTY INTERFACE_COMPILE_DEFINITIONS ${TBB_DEFINITIONS})
set_property(TARGET TBB::tbb PROPERTY INTERFACE_LINK_LIBRARIES      Threads::Threads ${CMAKE_DL_LIBS})
set_property(TARGET TBB::tbb PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS})
set_property(TARGET TBB::tbb PROPERTY IMPORTED_LOCATION             ${TBB_LIBRARIES})

Unfortunately since this seems to be a third party library there's probably little you can to other than modifying your installation and reporting this issue to the vendor and hoping for a fix in a future update.


Btw: There's some additional weirdness going on in this snippet: The use of plural in TBB_LIBRARIES could indicate that multiple values could be specified, but the IMPORTED_LOCATION property is supposed to be set to a single path to a binary, see the documentation of the target property.

Perhaps there could be a hack for dealing with the issue that could allow you to build your project regardless of the issues mentioned: Make sure to import TBB::tbb first and as the only component of the package; If the library does not automatically add additional libraries to the TBB_LIBRARIES variable this could result in the variable containing a single value. I would't rely on this being the case in future releases though...