diff --git a/scripts/cmake/CheckHeaderCompilation.cmake b/scripts/cmake/CheckHeaderCompilation.cmake
index a36092feba4800dcc19404cfd794f16386b4498e..addb233a92cddf6f3f2a35e41b8ffa764fbfc76e 100644
--- a/scripts/cmake/CheckHeaderCompilation.cmake
+++ b/scripts/cmake/CheckHeaderCompilation.cmake
@@ -15,6 +15,10 @@ add_custom_target(check-header
 # Checks header for standalone compilation
 function(_check_header_compilation TARGET)
 
+    if(NOT TARGET ${TARGET})
+        return()
+    endif()
+
     get_target_property(SOURCE_FILES ${TARGET} SOURCES)
     get_target_property(SOURCE_DIR ${TARGET} SOURCE_DIR)