cmake 使用与vcpkg一起安装的luajit

w46czmvw  于 2023-08-05  发布在  其他
关注(0)|答案(1)|浏览(161)

我有一个使用cmakevcpkg的c++项目。我想安装和使用luajit
我在vcpkg.json中添加了它:

{
  "name": "myproj",
  "version": "1.0.0",
  "dependencies": [
    "boost",
    "zeromq",
    "cppzmq",
    "yas",
    "luajit"
  ]
}

字符串
但是我不能在CMakeFiles.txt中使用它。如果我尝试添加它:

cmake_minimum_required (VERSION 3.22)

project (myproj-luaclientlib)

add_definitions (-DMYPROJ_LUACLIENTLIB_EXPORTS)

find_package (LuaJIT REQUIRED)

include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../)

set (PROJECT_SRC
  Author.cpp
)

add_library (${PROJECT_NAME} SHARED ${PROJECT_SRC})

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)


CMake找不到:

1> [CMake] CMake Error at P:/lib/vcpkg/scripts/buildsystems/vcpkg.cmake:855 (_find_package):
1> [CMake]   By not providing "FindLuaJIT.cmake" in CMAKE_MODULE_PATH this project has
1> [CMake]   asked CMake to find a package configuration file provided by "LuaJIT", but
1> [CMake]   CMake did not find one.
1> [CMake] 
1> [CMake]   Could not find a package configuration file provided by "LuaJIT" with any
1> [CMake]   of the following names:
1> [CMake] 
1> [CMake]     LuaJITConfig.cmake
1> [CMake]     luajit-config.cmake
1> [CMake] 
1> [CMake]   Add the installation prefix of "LuaJIT" to CMAKE_PREFIX_PATH or set
1> [CMake]   "LuaJIT_DIR" to a directory containing one of the above files.  If "LuaJIT"
1> [CMake]   provides a separate development package or SDK, be sure it has been
1> [CMake]   installed.
1> [CMake] Call Stack (most recent call first):
1> [CMake]   src/myproj/LuaClientLib/CMakeLists.txt:9 (find_package)


其他的图书馆工作得很好。
我做错了什么?在我的项目中使用luajit需要做什么?

k75qkfdt

k75qkfdt1#

LuaJIT没有-config.cmake。但是,它安装了一个*.pc文件,因此您可以只使用FindPkgConfig。因此,在清单中添加pkgconf作为主机依赖项,并执行以下操作:

find_package(PkgConfig REQUIRED)  
pkg_check_modules(LuaJIT REQUIRED IMPORTED_TARGET luajit)
target_link_libraries(<your_target> PRIVATE PkgConfig::LuaJIT)

字符串

相关问题