cmake install_error ai_generated true

CMake Error: CPack generator: DEB is not supported on this platform.

ID: cmake/cpack-generator-not-found

Also available as: JSON · Markdown · 中文
88%Fix Rate
85%Confidence
1Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
CMake 3.16 active — — —
CMake 3.20 active — — —
CMake 3.28 active — — —

Root Cause

CPack generator specified (e.g., DEB) is not available on the current operating system (e.g., Windows or macOS without dpkg).

generic

中文

指定的 CPack 生成器(例如 DEB)在当前操作系统上不可用(例如 Windows 或没有 dpkg 的 macOS)。

Official Documentation

https://cmake.org/cmake/help/latest/module/CPack.html

Workarounds

  1. 95% success Use a platform-conditional generator selection: if(WIN32) set(CPACK_GENERATOR "NSIS") else() set(CPACK_GENERATOR "DEB") endif(). This ensures only supported generators are used.
    Use a platform-conditional generator selection: if(WIN32) set(CPACK_GENERATOR "NSIS") else() set(CPACK_GENERATOR "DEB") endif(). This ensures only supported generators are used.
  2. 90% success For cross-platform builds, use a generic generator like TGZ or STGZ that works on all platforms: set(CPACK_GENERATOR "TGZ") in your CMakeLists.txt.
    For cross-platform builds, use a generic generator like TGZ or STGZ that works on all platforms: set(CPACK_GENERATOR "TGZ") in your CMakeLists.txt.
  3. 85% success Run cpack -G TGZ to override the generator from the command line instead of modifying the CMakeLists.txt.
    Run cpack -G TGZ to override the generator from the command line instead of modifying the CMakeLists.txt.

中文步骤

  1. 使用平台条件生成器选择:if(WIN32) set(CPACK_GENERATOR "NSIS") else() set(CPACK_GENERATOR "DEB") endif()。这确保只使用支持的生成器。
  2. 对于跨平台构建,使用通用生成器如 TGZ 或 STGZ,它们在所有平台上工作:在 CMakeLists.txt 中设置 set(CPACK_GENERATOR "TGZ")。
  3. 从命令行运行 cpack -G TGZ 覆盖生成器,而不是修改 CMakeLists.txt。

Dead Ends

Common approaches that don't work:

  1. 90% fail

    dpkg requires a Debian-based system to function correctly; cross-platform DEB generation is not supported by CPack without extensive toolchain setup.

  2. 100% fail

    The error is about platform support, not configuration duplication; the generator must be available on the host system.