CMP0002

警告

該方針的 OLD 行為已在 CMake 版本 4.0 中移除。該方針必須透過呼叫 cmake_minimum_required()cmake_policy() 設定為 NEW

邏輯目標名稱必須在全域中唯一。

Targets names created with add_executable(), add_library(), or add_custom_target() are logical build target names. Logical target names must be globally unique because:

  • Unique names may be referenced unambiguously both in CMake code and on make tool command lines.

  • Logical names are used by Xcode and Visual Studio IDE generators to produce meaningful project names for the targets.

The logical name of executable and library targets does not have to correspond to the physical file names built. Consider using the OUTPUT_NAME target property to create two targets with the same physical name while keeping logical names distinct. Custom targets must simply have globally unique names (unless one uses the global property ALLOW_DUPLICATE_CUSTOM_TARGETS with a Makefiles generator).

此方針於 CMake 版本 2.6.0 中引入。在 CMake 版本 4.0 移除之前,它可以透過 cmake_policy()cmake_minimum_required() 設定。如果未設定,CMake warned,並使用 OLD 行為。