FIND_PACKAGE_HANDLE_STANDARD_ARGS doesn't work in all project

my configuration

ubuntu 21.04
cmake 3.14 or 3.21.3

I got this error:

CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  /usr/lib/x86_64-linux-gnu/cmake/vtk-9.0/patches/99/FindX11.cmake:366 (find_package_handle_standard_args)

And thought that it is a library missing issue,but x11 do get installed.After a day struggling,I found any cmake which used command like:

FIND_PACKAGE_HANDLE_STANDARD_ARGS(*** REQUIRED_VARS)

will give similar error,and I realized that:

 FIND_PACKAGE_HANDLE_STANDARD_ARGS doesn't work in all projects.

would you please tell me the possible approches to solve this problem?

How is it not working? Do you have the libx11-dev package installed? FPHSA is well-tested, so I’m more inclined to say that something is up on the machine. Does the output of cmake --debug-find help figure out why X11_X11_LIB isn’t found?