How to re-use sub-target header-files/dependencies

That is a bad hack, do you know how modern cmake works?

include(FetchContent) 
FetchContent_Declare( cjson 
GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git 
GIT_TAG "v1.7.18" GIT_SHALLOW TRUE )

 SET(ENABLE_CJSON_TEST OFF CACHE BOOL "Enable cJSON tests") 

FetchContent_MakeAvailable(cjson) 

function(USE_CJSON target) 
   target_link_libraries(${target} PUBLIC cjson) 
endfunction()