Skip to content

nv_test could not add_dependencies of header-ONLY library #2727

Closed
@QiJune

Description

@QiJune

eigen3 is a header only library and we take eigen3 as a cmake external library.
And in my device_context implementation #2709 , the device_context depends on eigen3.
So, we must have eigen3 download before device_context_test compiled.
However, if i write
nv_test(device_context_test SRCS device_context_test.cc DEPS place eigen3 glog gflags)

There will be such error:

CMake Error at cmake/generic.cmake:246 (target_link_libraries):
  Target "eigen3" of type UTILITY may not be linked into another target.  One
  may link only to STATIC or SHARED libraries, or to executables with the
  ENABLE_EXPORTS property set.

I just hack the nv_test in generic.cmake as follows:

function(nv_test TARGET_NAME)
  if (WITH_GPU AND WITH_TESTING)
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs SRCS INCS DEPS)
    cmake_parse_arguments(nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    cuda_add_executable(${TARGET_NAME} ${nv_test_SRCS})
    target_link_libraries(${TARGET_NAME} ${nv_test_DEPS} gtest gtest_main)
    add_dependencies(${TARGET_NAME} ${nv_test_INCS} ${nv_test_DEPS} gtest gtest_main)
    add_test(${TARGET_NAME} ${TARGET_NAME})
  endif()
endfunction(nv_test)

And change my compiling command to

nv_test(device_context_test SRCS device_context_test.cc INCS eigen3 DEPS place glog gflags)

And it works.

So, how can we handle this circumstance, and is the hacking way appropriate?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions