Skip to content

Commit

Permalink
Guard against re-adding an already exisitng target
Browse files Browse the repository at this point in the history
  • Loading branch information
chillenzer committed Jan 16, 2025
1 parent db41213 commit d09d548
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmake/add_controlled.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ function(add_controlled NAME)
set(ADD_CONTROLLED_PREFIX ${PROJECT_NAME})
endif()

if (TARGET ${NAME} OR TARGET ${NAME}::${NAME})
message("There already exists a target for dependency ${NAME}. Not addding ${NAME} for ${ADD_CONTROLLED_PREFIX} again.")
return()
endif()


set(ALL_OPTIONS "ON;ON_ALLOW_FETCH;ON_ALWAYS_FETCH;AUTO;OFF")
if(ADD_CONTROLLED_REQUIRED)
# This is a required dependency, so we're only free to choose how, not if, we want to use it.
Expand Down

0 comments on commit d09d548

Please sign in to comment.