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: Yuval Peress <peress@google.com>
This commit is contained in:
parent
9cebf732ee
commit
ffb861d1a3
2 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue