ROOT_GENERATE_DICTIONARY with header only target?

Thanks for this tip. Yes, I tried with rootcling and it does work with only header files. But I also found that rootcling also generates a source file for the dictionary, which could be the reason why header-only target can’t work at all.

Therefore I found the solution with this info. Instead of declaring the target with INTERFACE:

add_library(myData INTERFACE)
target_include_directories(myData PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(myData PRIVATE ROOT::RIO)

declare the target with either SHARED or STATIC:

add_library(myData SHARED)
target_include_directories(myData PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(myData PRIVATE ROOT::RIO)

Then it works as expected.