我试图将柯南2和Qt6集成到一个学习项目中,但在开始构建时出现错误。
柯南档案:
[requires]
qt/6.6.1
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
字符串
柯南简介:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=193
os=Windows
型
CmakeLists.txt:
cmake_minimum_required(VERSION 3.5)
set(TARGET_NAME test)
set(QT_VERSION_MAJOR 6)
project(${TARGET_NAME} VERSION 0.1 DESCRIPTION "test qt")
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
add_executable(${TARGET_NAME}
main.cpp
)
if(MSVC)
target_compile_options(${TARGET_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic -Werror)
endif()
target_link_libraries(${TARGET_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
型
我的命令序列:
conan install . --build=missing
cd build
cmake ..
型
我得到了这个错误:
CMake Error at CMakeLists.txt:15 (find_package):
By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt6", but
CMake did not find one.
Could not find a package configuration file provided by "Qt6" with any of
the following names:
Qt6Config.cmake
qt6-config.cmake
Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
to a directory containing one of the above files. If "Qt6" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
型
我该如何解决此问题?
1条答案
按热度按时间4jb9z9bj1#
在《柯南2》中,你需要使用一种不同的调用方式,正如我所学到的那样。
在源目录中,运行
conan install . --output-folder=build --build=missing
,然后运行cd build
并调用CMake,