初步编译QT5.15.2+VS2019+VTK8.2.0

Posted yantuguiguziPGJ

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了初步编译QT5.15.2+VS2019+VTK8.2.0相关的知识,希望对你有一定的参考价值。

目录

一  编译结果

二  cmake库编译配置

三  cmake应用配置脚本

四  推荐链接


一  编译结果

编译完没有QT,可能是QT版本太高、web组件不匹配、python3.9版本太高。

二  cmake库编译配置

三  cmake应用配置脚本

这样就能qt和vs一起debug了。

nicanor-romero/QtVtk: An integration between Qt Quick Controls 2 and VTK for 3D rendering (github.com)

###########
# 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 $ENVQTDIR)

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 $ENVVTK_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条消息) 初步编译QT5.15.2+VS2019+VTK8.1.0_yantuguiguziPGJ的博客-CSDN博客


(600条消息) VS2019编译VTK-9.1.0+Qt5.15.2_yantuguiguziPGJ的博客-CSDN博客

(600条消息) 三战VS2019编译VTK7.1+Qt5.15.2_yantuguiguziPGJ的博客-CSDN博客

(600条消息) VTK(0)---CMake工程_老邹的博客-CSDN博客

(600条消息) 如何学习VTK_阿兵-AI医疗的专栏-CSDN博客_vtk学习

QuickVtk/build.md at master · qCring/QuickVtk (github.com)

以上是关于初步编译QT5.15.2+VS2019+VTK8.2.0的主要内容,如果未能解决你的问题,请参考以下文章

编译QCefView+VS2019+QT5.15.2

编译QCefView+VS2019+QT5.15.2

VS2019编译VTK-9.1.0+Qt5.15.2

VS2019编译VTK-9.1.0+Qt5.15.2

三战VS2019编译VTK7.1+Qt5.15.2

三战VS2019编译VTK7.1+Qt5.15.2