Exporting Targets from the Build Tree and immediately using find_package()

My problem is as follows (cmake version 3.29.4):
in top CMakeLists.txt has added two subdirectories

    add_subdirectory(fmt)
    add_subdirectory(tests)

And in file fmt/CMakeLists.txt I export a target by

include(CMakePackageConfigHelpers)
configure_package_config_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install/Config.in.cmake
    ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/FmtConfig.cmake
    INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fmt)
write_basic_package_version_file(
    "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/FmtConfigVersion.cmake"
    VERSION "${target_version}"
    COMPATIBILITY AnyNewerVersion)
export(
    EXPORT FmtTargets
    NAMESPACE tests::
    FILE ${CMAKE_BINARY_DIR}/fmt/lib/cmake/FmtTargets.cmake)

Then I find_package(Fmt REQUIRED) in the tests/CMakeLists.txt

set(Fmt_DIR ${CMAKE_BINARY_DIR}/fmt/lib/cmake/)
find_package(Fmt REQUIRED)

There is FmtConfig.cmake available In directory ${CMAKE_BINARY_DIR}/fmt/lib/cmake
ls ${CMAKE_BINARY_DIR}/fmt/lib/cmake has follow output after I run cmake --build

FmtConfig.cmake  FmtConfigVersion.cmake

But it raise an error

[cmake] CMake Error at ${CMAKE_BINARY_DIR}/fmt/lib/cmake/FmtConfig.cmake:27 (include):
[cmake]   include could not find requested file:
[cmake] 
[cmake]     ${CMAKE_BINARY_DIR}/fmt/lib/cmake/FmtTargets.cmake
[cmake] Call Stack (most recent call first):
[cmake]   tests/fmt/CMakeLists.txt:2 (find_package)

The problem is FmtTargets.cmake has not generated when call find_package() in tests/CMakeLists.txt.

If I first build fmt/CMakeLists.txt and then build tests/CMakeLists.txt it works.

Would someon please help me how to make find_package can find the FmtTargets.cmake after it actually been generated when no seperately running build fmt/CMakeLists.txt first, instead I can run single build command in top CMakeLists.txt ?

Regards,

huiyan