From 3039cca242bcb7ada82c43a03afc12c9f683995a Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 9 Apr 2018 18:59:24 -0700 Subject: [PATCH] add facility to link libraries to tests (#1850) --- cmake/Modules/BuildUtils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/Modules/BuildUtils.cmake b/cmake/Modules/BuildUtils.cmake index d3e148b10..cd8a107b4 100644 --- a/cmake/Modules/BuildUtils.cmake +++ b/cmake/Modules/BuildUtils.cmake @@ -226,3 +226,13 @@ function(ADD_RAY_TEST REL_TEST_NAME) endif() set_tests_properties(${TEST_NAME} PROPERTIES LABELS "unittest") endfunction() + +# A wrapper for target_link_libraries() that is compatible with NO_TESTS. +function(RAY_TEST_LINK_LIBRARIES REL_TEST_NAME) + if(NO_TESTS) + return() + endif() + get_filename_component(TEST_NAME ${REL_TEST_NAME} NAME_WE) + + target_link_libraries(${TEST_NAME} ${ARGN}) +endfunction()