Commit ffb861d1 authored by Yuval Peress's avatar Yuval Peress Committed by Carles Cufi
Browse files

unittest: warn users of deprecated SOURCES



If users set SOURCES before find_package for unit tests, we'll warn them
that this code path will no longer be supported and provide the correct
way of doing things moving forward.

Signed-off-by: default avatarYuval Peress <peress@google.com>
parent 9cebf732
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -73,5 +73,12 @@ if(NOT "${Deprecated_FIND_COMPONENTS}" STREQUAL "")
                 "${Deprecated_FIND_COMPONENTS}")
endif()

if("SOURCES" IN_LIST Deprecated_FIND_COMPONENTS)
  message(DEPRECATION
      "Setting SOURCES prior to calling find_package() for unit tests is deprecated."
      "To add sources after find_package() use:\n"
      "    target_sources(testbinary PRIVATE <source-file.c>)")
endif()

set(Deprecated_FOUND True)
set(DEPRECATED_FOUND True)
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ if(NOT SOURCES AND EXISTS main.c)
endif()

add_executable(testbinary ${SOURCES})
find_package(Deprecated COMPONENTS SOURCES)
add_library(test_interface INTERFACE)
target_link_libraries(testbinary PRIVATE test_interface)