add_custom_target(target1 ALL)
target_sources(target1 PRIVATE main.cpp)
get_property(actualProp1 TARGET target1 PROPERTY SOURCES)
set(desiredProp1 main.cpp)
if(NOT desiredProp1 STREQUAL actualProp1)
  message("source property not set. desired: \"${desiredProp1}\" actual: \"${actualProp1}\"")
endif()

add_custom_target(target2 ALL SOURCES main.cpp)
target_sources(target2 PRIVATE empty_1.cpp empty_2.cpp)
target_sources(target2 PRIVATE empty_3.cpp)
get_property(actualProp2 TARGET target2 PROPERTY SOURCES)
set(desiredProp2 main.cpp empty_1.cpp empty_2.cpp empty_3.cpp)
if (NOT desiredProp2 STREQUAL actualProp2)
  message("source property not set. desired: \"${desiredProp2}\" actual: \"${actualProp2}\"")
endif()
