[英]Installing Qt5Svg with Conan
So I'm trying to port this project I've been working on from qmake to cmake.所以我试图将我一直在研究的这个项目从 qmake 移植到 cmake。 I also plan to get my qt dependencies through Conan and get a CI service going.
我还计划通过 Conan 获取我的 qt 依赖项并启动 CI 服务。 Getting most of the qt libraries was fairly easy using qt/5.12.4@bincrafters/stable.
使用 qt/5.12.4@bincrafters/stable 可以很容易地获得大部分 qt 库。 Except one.
除了一个。 For some reason, the Qt5Svg module is not included with this package and I couldn't find a good solution for this so I've hit a dead end.
出于某种原因,这个包中没有包含 Qt5Svg 模块,我找不到一个好的解决方案,所以我走到了死胡同。 Bellow are the error messages and the relevant cmake files.
下面是错误消息和相关的 cmake 文件。
Error message错误信息
[CMake] CMake Error at src/analysis_tool/CMakeLists.txt:33 (find_package):
[CMake] CMake 错误在 src/analysis_tool/CMakeLists.txt:33 (find_package):
[CMake] By not providing "FindQt5Svg.cmake" in CMAKE_MODULE_PATH this project has[CMake] 通过不在 CMAKE_MODULE_PATH 中提供“FindQt5Svg.cmake”这个项目有
[CMake] asked CMake to find a package configuration file provided by "Qt5Svg", but[CMake]要求CMake找到“Qt5Svg”提供的包配置文件,但是
[CMake] CMake did not find one.[CMake] CMake 没有找到。
[CMake][CMake]
[CMake] Could not find a package configuration file provided by "Qt5Svg" with any[CMake] 找不到“Qt5Svg”提供的包配置文件
[CMake] of the following names:[CMake] 具有以下名称:
[CMake][CMake]
[CMake] Qt5SvgConfig.cmake[CMake] Qt5SvgConfig.cmake
[CMake] qt5svg-config.cmake[CMake] qt5svg-config.cmake
[CMake][CMake]
[CMake] Add the installation prefix of "Qt5Svg" to CMAKE_PREFIX_PATH or set【CMake】在CMAKE_PREFIX_PATH中添加“Qt5Svg”的安装前缀或设置
[CMake] "Qt5Svg_DIR" to a directory containing one of the above files.[CMake] "Qt5Svg_DIR" 到包含上述文件之一的目录。 If "Qt5Svg"
如果“Qt5Svg”
[CMake] provides a separate development package or SDK, be sure it has been[CMake] 提供了单独的开发包或SDK,请确保已经
[CMake] installed.[CMake] 已安装。
Conan.cmake (which is called from the top level CMakeLists.txt file) Conan.cmake (从顶层 CMakeLists.txt 文件调用)
macro(run_conan)
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
message(${CMAKE_BINARY_DIR};)
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_add_remote(
NAME
bincrafters
URL
https://api.bintray.com/conan/bincrafters/public-conan)
conan_cmake_run(
REQUIRES
qt/5.12.4@bincrafters/stable
OPTIONS
${CONAN_EXTRA_OPTIONS}
BASIC_SETUP
CMAKE_TARGETS # individual targets to link to
BUILD
missing)
endmacro()
Executable CMake可执行的 CMake
cmake_minimum_required(VERSION 3.8)
project(codego)
file(GLOB CODEGO_SOURCES "src/*.cpp")
file(GLOB CODEGO_HEADERS "include/*.h")
file(GLOB CODEGO_UIS "ui/*.ui")
file(GLOB CODEGO_RES "res/*.qrc")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS ui)
add_executable(${PROJECT_NAME} src/main.cpp ${CODEGO_UIS})
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_include_directories(${PROJECT_NAME} PUBLIC ui)
target_include_directories(${PROJECT_NAME} PUBLIC res)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Svg REQUIRED)
# Add the include directories for the Qt 5 modules to the compile lines.
include_directories(${Qt5Core_INCLUDE_DIRS}/QtCore)
include_directories(${Qt5Gui_INCLUDE_DIRS}/QtGui)
include_directories(${Qt5Widgets_INCLUDE_DIRS}/QtWidgets)
include_directories(${Qt5Xml_INCLUDE_DIRS}/QtXml)
include_directories(${Qt5Xml_INCLUDE_DIRS}/QtSvg)
# Use the compile definitions defined in the Qt 5 modules
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Gui_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5Xml_DEFINITIONS})
add_definitions(${Qt5Svg_DEFINITIONS})
qt5_wrap_ui(WRAP_UI_MOC ${CODEGO_UIS})
qt5_wrap_cpp(WRAP_HEADER_MOC ${CODEGO_HEADERS})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR})
include_directories(include)
add_library(PROJECT_LIBRARIES SHARED
${CODEGO_SOURCES}
${WRAP_UI_MOC}
${WRAP_HEADER_MOC})
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Xml
Qt5::Svg)
target_link_libraries(${PROJECT_NAME} PROJECT_LIBRARIES)
All the other modules seem to be installing just fine (Qt5Core Qt5Widgets etc) and I can find them in the .conan folder but not the Qt5Svg one.所有其他模块似乎都安装得很好(Qt5Core Qt5Widgets 等),我可以在 .conan 文件夹中找到它们,但不能在 Qt5Svg 文件夹中找到它们。 Thanks for taking the time to read through this.
感谢您花时间阅读本文。
You need to provide and option to build qtsvg
with qt package.您需要提供使用 qt 包构建
qtsvg
选项。 Your conan_cmake_run
should look as follow:您的
conan_cmake_run
应如下所示:
cmake_minimum_required(VERSION 3.8)
project(codego)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS ui)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
message(${CMAKE_BINARY_DIR};)
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_add_remote(
NAME
bincrafters
URL
https://api.bintray.com/conan/bincrafters/public-conan)
conan_cmake_run(
REQUIRES qt/5.14.1@bincrafters/stable
OPTIONS qt:qtsvg=True
BASIC_SETUP
CMAKE_TARGETS
BUILD missing
)
EDIT: I used qt 5.14.1 as 5.12.4 was failing to build on my osx machine due to some outdated packages.编辑:我使用了 qt 5.14.1,因为 5.12.4 由于一些过时的软件包而无法在我的 osx 机器上构建。 Now when I do
ls
:现在当我做
ls
:
ls ~/.conan/data/qt/5.14.1/bincrafters/stable/package/<package_id>/lib/cmake/
gives me Qt5Svg
among folders在文件夹中给我
Qt5Svg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.