# =============================================================================
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on
# =============================================================================
include(${rapids-cmake-dir}/export/export.cmake)

cmake_minimum_required(VERSION 4.0)
project(FakEProJecT LANGUAGES CXX VERSION 3.1.4)

add_library(fakeLib1 INTERFACE)
add_library(fakeLib2 INTERFACE)
set_target_properties(fakeLib2 PROPERTIES EXPORT_NAME namespacefor2only)
install(TARGETS fakeLib1 fakeLib2 EXPORT fake_set)

rapids_export(BUILD FakEProJecT EXPORT_SET fake_set LANGUAGES CXX)

# Add a custom command that generates a second project that verifies our target was exported with
# the correct namespace
file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt"
     [=[
cmake_minimum_required(VERSION 4.0)
project(verify_build_targets LANGUAGES CXX)
message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake")
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake")
  message(FATAL_ERROR "rapids_export failed to generate correct config file name")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/../fakeproject-targets.cmake")
if(NOT TARGET fakeLib1)
  message(FATAL_ERROR "rapids_export failed to generate correct namespace targets")
endif()
if(NOT TARGET namespacefor2only)
  message(FATAL_ERROR "rapids_export failed to generate correct namespace targets")
endif()
  ]=])

add_custom_target(verify_target_file ALL
                  COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build"
                  COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify"
                          -B="${CMAKE_BINARY_DIR}/verify/build")
