NOT TARGET meaning?

I see expressions like this in cmake files:

if(NOT TARGET JSONUtils::JSONUtils)
    include("${JSONUtils_CMAKE_DIR}/JSONUtilsTargets.cmake")
endif()

What exactly does this mean? By itself I think “NOT TARGET” means variable TARGET is not set, but in conjunction with JSONUtils:JSONUtils?
Thanks!

The TARGET operator means “is the following argument the name of a CMake target”. In this case, if(NOT TARGET JSONUtils::JSONUtils) evaluates to true if there is no target called JSONUtils::JSONUtils.

1 Like