一 编译结果
编译完没有QT,可能是QT版本太高、web组件不匹配、python3.9版本太高。
二 cmake库编译配置
三 cmake应用配置脚本
这样就能qt和vs一起debug了。
###########
# Project #
###########
cmake_minimum_required(VERSION 3.4)
project(QtVtk)
#######################
# Folder organisation #
#######################
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
# Indicate that previous configuration exists
set(CONFIGURED TRUE)
###########
# Targets #
###########
add_subdirectory(src)
###########
# Project #
###########
set(EXENAME QtVtk)
if(NOT CONFIGURED)
cmake_minimum_required(VERSION 3.4)
project(${EXENAME})
set(PROJECT_SOURCE_DIR ../)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
link_directories(${PROJECT_SOURCE_DIR}/build)
# Indicate that previous configuration exists
set(CONFIGURED TRUE)
endif(NOT CONFIGURED)
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()
#########################
# External Dependencies #
#########################
# Find the Qt libraries
set(CMAKE_PREFIX_PATH $ENV{
QTDIR})
find_package(Qt5Quick REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5QuickControls2 REQUIRED)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# VTK Libraries
set(VTK_DIR $ENV{
VTK_DIR})
find_package(VTK REQUIRED NO_MODULE)
#include(${VTK_USE_FILE})
# Headers directories
include_directories(${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src
)
###########
# Targets #
###########
# Add QML files to project tree in Qt Creator
file(GLOB QML_DESKTOP "../resources/*.qml")
add_custom_target(QML_files SOURCES ${QML_DESKTOP})
# Sources
set (SOURCES
main.cpp
CanvasHandler.cpp
CommandModel.cpp
CommandModelAdd.cpp
CommandModelTranslate.cpp
Model.cpp
ProcessingEngine.cpp
QVTKFramebufferObjectItem.cpp
QVTKFramebufferObjectRenderer.cpp
)
if (NOT APPLE)
add_definitions(-std=c++11 -fext-numeric-literals -DPTHREADS_USED)
else()
add_definitions(-std=c++11)
endif()
# Qt Resources
qt5_add_resources(RESOURCES qml.qrc)
# Build executable
if (WIN32)
add_executable(${EXENAME} WIN32 ${HEADERS} ${SOURCES} ${RESOURCES})
else()
add_executable(${EXENAME} ${HEADERS} ${SOURCES} ${RESOURCES})
endif()
# Link to libraries
target_link_libraries(${EXENAME} Qt5::Quick Qt5::Widgets Qt5::Qml Qt5::QuickControls2 ${VTK_LIBRARIES} ${SYSTEM_LIBS})
四 推荐链接
(600条消息) 三战VS2019编译VTK7.1+Qt5.15.2_yantuguiguziPGJ的博客-CSDN博客
(600条消息) VTK(0)---CMake工程_老邹的博客-CSDN博客