CMake错误,包括Ubuntu 22中的IXWebSocket(适用于MacOS 12.6)

wqlqzqxt  于 2022-11-11  发布在  Mac
关注(0)|答案(1)|浏览(171)

内容:

我有一个在MacOS12.6上构建的cpp程序,其中包含以下CMakeLists.txt文件。

cmake_minimum_required(VERSION 3.19.0)
project(cpp-test VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_executable(cpp-test main.cpp)
add_library(test-helpers main.cpp ${PROJECT_SOURCE_DIR}/helpers.hpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

# this is super important in order for cmake to include the vcpkg search/lib paths!

set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")

# find library and its headers

find_path(IXWEBSOCKET_INCLUDE_DIR ixwebsocket/IXWebSocket.h)
find_library(IXWEBSOCKET_LIBRARY ixwebsocket)
find_package(OpenSSL REQUIRED)
find_package(CURL REQUIRED)

# include headers

include_directories(${IXWEBSOCKET_INCLUDE_DIR} ${CURL_INCLUDE_DIR})

# Cmake will automatically fail the generation if the lib was not found, i.e is set to NOTFOUND

target_link_libraries(
  ${PROJECT_NAME} PRIVATE
  ${IXWEBSOCKET_LIBRARY}
  OpenSSL::SSL
  OpenSSL::Crypto
  ${CURL_LIBRARIES}
  "-framework Foundation"
  "-framework Security"
  "-lz"
)

这编译得很好。但是,当我试图将它拉入我的Ubuntu虚拟机并试图构建它/build> cmake ..时,我得到了以下错误

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of "cpp-test":

    "IXWEBSOCKET_INCLUDE_DIR-NOTFOUND"

CMake Error in CMakeLists.txt:
  Found relative path while evaluating include directories of
  "test-helpers":

    "IXWEBSOCKET_INCLUDE_DIR-NOTFOUND"

-- Generating done

"我所做的一切"

  • 我已经安装了vcpkg并创建了我的符号链接ln -s /path/to/vcpkg /usr/local/bin/vcpkg
  • 我已经通过vcpkg install ixwebsocket安装了ixwebsocket,但似乎没有正确解析CMAKE_TOOLCHAIN_FILE。

我有点迷路了,如果你能帮我

bq3bfh9z

bq3bfh9z1#

这不是一个很好的解决这个问题的方法,但是我最终通过CMake构建ixwebsocket来解决这个问题。
看起来vcpkg与我的VM中的linux发行版不兼容。

相关问题