首页 > 解决方案 > 无法配置 websocketpp 示例 CMakeLists.txt 文件

问题描述

当尝试从 Windows 10 上的 CMake GUI 配置websocketppexamples/echo_server存储库中文件夹中的 CMakeLists.txt 文件时,我得到以下结果:

CMake Error at CMakeLists.txt:5 (init_target):
  Unknown CMake command "init_target".


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.13)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

Configuring incomplete, errors occurred!
See also "D:/third-party-software/websocketpp/examples/echo_server/build/CMakeFiles/CMakeOutput.log".

为什么我会收到错误消息Unknown CMake command "init_target",我该怎么办?我已经用谷歌搜索了它,但我只得到了那个确切的消息,它是关于构建 websocketpp,而不是一个单独的例子。

标签: c++websocketcmake

解决方案


init_target不是 cmake 命令。这是一个在cmake/CMakeHelpers.cmake文件中定义的自定义 marco。

您应该将它包含include(CMakeHelpers)在您CMakeLists.txt的使用init_target和其他自定义命令中。


推荐阅读