Issue
I've a c++ project that uses cmake
and vcpkg
. I want to install and use luajit.
I've added it in my vcpkg.json
:
{
"name": "myproj",
"version": "1.0.0",
"dependencies": [
"boost",
"zeromq",
"cppzmq",
"yas",
"luajit"
]
}
But then I'm not able to use it in a CMakeFiles.txt
. If I try to add it:
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
does not find it:
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)
Other libraries works well.
What I'm doing wrong? What should I do in order to use luajit
in my project?
Solution
LuaJIT does not have a -config.cmake
. However, it installs a *.pc
file so you can just use FindPkgConfig
. So add pkgconf
as a host dependency in your manifest and do:
find_package(PkgConfig REQUIRED)
pkg_check_modules(LuaJIT REQUIRED IMPORTED_TARGET luajit)
target_link_libraries(<your_target> PRIVATE PkgConfig::LuaJIT)
Answered By - Alexander Neumann Answer Checked By - Robin (WPSolving Admin)