Advertisement
ajith_97

TreeView CMake

Sep 8th, 2022
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 1.01 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.16)
  2.  
  3. project(treeview VERSION 0.1 LANGUAGES CXX)
  4.  
  5. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  6.  
  7. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  8. set(CMAKE_AUTOMOC ON)
  9. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  10.  
  11. find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick Widgets)
  12.  
  13. qt_add_executable(treeview
  14.     treemodel.h treemodel.cpp
  15.     treeitem.h treeitem.cpp
  16.     main.cpp
  17. )
  18.  
  19. qt_add_qml_module(treeview
  20.     URI TreeViewExample
  21.     VERSION 1.0
  22.     SOURCES
  23.     QML_FILES
  24.         main.qml
  25. )
  26.  
  27. set_target_properties(treeview PROPERTIES
  28.     WIN32_EXECUTABLE TRUE
  29. )
  30.  
  31.  
  32. target_link_libraries(treeview PRIVATE
  33.     Qt::Widgets
  34.     Qt::Core
  35.     Qt::Qml
  36.     Qt::Quick
  37. )
  38.  
  39. target_compile_definitions(treeview PRIVATE
  40.     APP_NAME=tree_view
  41.     TOP_BUILDDIR=${CMAKE_BINARY_DIR}
  42. )
  43.  
  44. list(APPEND QML_IMPORT_PATH ${CMAKE_CURRENT_BINARY_DIR})
  45. list(REMOVE_DUPLICATES QML_IMPORT_PATH)
  46. set(QML_IMPORT_PATH ${QML_IMPORT_PATH} CACHE STRING "Automate QML_IMPORT_PATH for QtCreator" FORCE)
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement