{
  "id": "cmake/export-requires-cpp-standard",
  "signature": "CMake Error: export requires C++ standard to be set for target 'mylib'",
  "signature_zh": "CMake错误：目标'mylib'需要设置C++标准才能导出",
  "regex": "CMake Error: export requires C\\+\\+ standard to be set for target '[^']+'",
  "domain": "cmake",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "The EXPORT command requires that the target has a CXX_STANDARD property set, but the target lacks it, often due to missing target_compile_features or CMAKE_CXX_STANDARD.",
  "root_cause_type": "generic",
  "root_cause_zh": "EXPORT命令要求目标具有CXX_STANDARD属性，但目标缺少该属性，通常是因为缺少target_compile_features或CMAKE_CXX_STANDARD。",
  "versions": [
    {
      "version": "CMake 3.24",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.28",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.30",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set CMAKE_CXX_STANDARD in CMakeLists.txt after add_library",
      "why_fails": "Setting CMAKE_CXX_STANDARD globally may not propagate to exported targets if not set before the target definition.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add 'set(CMAKE_CXX_STANDARD 17)' without target_compile_features",
      "why_fails": "The export check specifically looks for target_compile_features or explicit CXX_STANDARD property on the target; global variable may be ignored.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use INTERFACE property instead of PUBLIC for compile features",
      "why_fails": "INTERFACE properties are not sufficient for export; they must be PUBLIC or PRIVATE to be visible.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add target_compile_features(mylib PUBLIC cxx_std_17) before export command",
      "success_rate": 0.85,
      "how": "Add target_compile_features(mylib PUBLIC cxx_std_17) before export command",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set CXX_STANDARD property explicitly on the target: set_target_properties(mylib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)",
      "success_rate": 0.9,
      "how": "Set CXX_STANDARD property explicitly on the target: set_target_properties(mylib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use cmake_policy(SET CMP0086 NEW) to relax the check if the target already has C++ standard from dependencies",
      "success_rate": 0.75,
      "how": "Use cmake_policy(SET CMP0086 NEW) to relax the check if the target already has C++ standard from dependencies",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add target_compile_features(mylib PUBLIC cxx_std_17) before export command",
    "Set CXX_STANDARD property explicitly on the target: set_target_properties(mylib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)",
    "Use cmake_policy(SET CMP0086 NEW) to relax the check if the target already has C++ standard from dependencies"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/policy/CMP0086.html",
  "official_doc_section": null,
  "error_code": "CMP0086",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}