VTK_Qt_Cmake ╰+攻爆jí腚メ 2023-06-27 12:35 16阅读 0赞 cmake_minimum_required(VERSION 3.10) project(VTKTest) set(CMAKE_CXX_STANDARD 14) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) #set(CMAKE_PREFIX_PATH "/home/ueg-pc1/Qt5.12.5/5.12.5/gcc_64/lib/cmake") find_package (Qt5 COMPONENTS Core Widgets REQUIRED) FIND_PACKAGE(VTK REQUIRED) IF (VTK_FOUND) MESSAGE(STATUS "VTK found.") INCLUDE(${VTK_USE_FILE}) ENDIF() IF(Qt5_FOUND) MESSAGE(STATUS "Qt5 found.") ENDIF() add_executable(VTKTest main.cpp mainwindow.cpp mainwindow.h mainwindow.ui) target_link_libraries(VTKTest ${VTK_LIBRARIES}) 另外一种写法: set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) #set(CMAKE_PREFIX_PATH "/home/ueg-pc1/Qt5.12.5/5.12.5/gcc_64/lib/cmake") find_package(Qt5 COMPONENTS Widgets REQUIRED) IF(Qt5_FOUND) MESSAGE(STATUS "Qt5 found.") ENDIF() FIND_PACKAGE(VTK REQUIRED) IF (VTK_FOUND) MESSAGE(STATUS "VTK found.") INCLUDE(${VTK_USE_FILE}) ENDIF() set (SOURCES main.cpp mainwindow.cpp ) set (HEADERS mainwindow.h mainwindow.ui ) add_executable(VTK_CT ${HEADERS} ${SOURCES} ) target_link_libraries(VTK_CT PRIVATE Qt5::Widgets ${VTK_LIBRARIES} )
还没有评论,来说两句吧...