Skip to content

Commit 4f6f18e

Browse files
committed
FindObjectBoxGenerator.cmake: improve error message if target is unavailable
1 parent 5c38a0c commit 4f6f18e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmake/FindObjectBoxGenerator.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ function (add_obx_schema)
422422
set(prev_cppfile ${cppfile})
423423
list(APPEND sources ${cppfile} ${hppfile})
424424
endforeach()
425+
426+
if (NOT TARGET ${ARG_TARGET})
427+
# Fail fast with a nice error message if the target does not exist.
428+
# Otherwise, it would fail on target_sources() with a not so straight-forward error message.
429+
message(FATAL_ERROR "add_obx_schema(): the given target \"${ARG_TARGET}\" was not found. Make sure to define it before calling add_obx_schema().")
430+
endif()
425431
target_sources(${ARG_TARGET} PRIVATE ${sources})
426432
if (NOT ARG_INSOURCE)
427433
target_include_directories(${ARG_TARGET} PRIVATE ${OBX_GEN_OUTPUT_DIR_HEADERS})

0 commit comments

Comments
 (0)