Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMAKE: Make CMake config idempotent w.r.t. target discovery and creation #9622

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cmake/ucx-targets.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
set(exec_prefix "@exec_prefix@")

set(_ucx_targets_defined "")
set(_ucx_targets_not_defined "")
set(_ucx_expected_targets "")
foreach(_ucx_expected_target IN ITEMS ucx::ucs ucx::uct ucx::ucp)
list(APPEND _ucx_expected_targets "${_ucx_expected_target}")
if(TARGET "${_ucx_expected_target}")
list(APPEND _ucx_targets_defined "${_ucx_expected_target}")
else()
list(APPEND _ucx_targets_not_defined "${_ucx_expected_target}")
endif()
endforeach()
unset(_ucx_expected_target)
if(NOT _ucx_targets_not_defined)
unset(_ucx_targets_defined)
unset(_ucx_targets_not_defined)
unset(_ucx_expected_targets)
unset(CMAKE_IMPORT_FILE_VERSION)
return()
endif()
if(NOT _ucx_targets_defined STREQUAL "")
string(REPLACE ";" ", " _ucx_targets_defined_text "${_ucx_targets_defined}")
string(REPLACE ";" ", " _ucx_targets_not_defined_text "${_ucx_targets_not_defined}")
message(FATAL_ERROR "Some (but not all) ucx targets were already defined.\nTargets Defined: ${_ucx_targets_defined_text}\nTargets not yet defined: ${_ucx_targets_not_defined_text}\n")
tvegas1 marked this conversation as resolved.
Show resolved Hide resolved
endif()
unset(_ucx_targets_defined)
unset(_ucx_targets_not_defined)
unset(_ucx_expected_targets)

add_library(ucx::ucs SHARED IMPORTED)

set_target_properties(ucx::ucs PROPERTIES
Expand Down
Loading