Advertisement
Parallel_1986

Cmake

Aug 1st, 2023
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.24 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.5)
  2.  
  3. project(Test_aplication VERSION 0.1 LANGUAGES CXX)
  4.  
  5. set(CMAKE_AUTOUIC ON)
  6. set(CMAKE_AUTOMOC ON)
  7. set(CMAKE_AUTORCC ON)
  8.  
  9. set(CMAKE_CXX_STANDARD 17)
  10. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  11.  
  12. find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
  13. find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
  14.  
  15. set(PROJECT_SOURCES
  16.         main.cpp
  17.         widget.cpp
  18.         widget.h
  19. )
  20.  
  21. if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
  22.     qt_add_executable(Test_aplication
  23.         MANUAL_FINALIZATION
  24.         ${PROJECT_SOURCES}
  25.     )
  26. # Define target properties for Android with Qt 6 as:
  27. #    set_property(TARGET Test_aplication APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
  28. #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
  29. # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
  30. else()
  31.     if(ANDROID)
  32.         add_library(Test_aplication SHARED
  33.             ${PROJECT_SOURCES}
  34.         )
  35. # Define properties for Android with Qt 5 after find_package() calls as:
  36. #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
  37.     else()
  38.         add_executable(Test_aplication
  39.             ${PROJECT_SOURCES}
  40.             circle.h circle.cpp
  41.             #testclass.h testclass.cpp
  42.  
  43.  
  44.         )
  45.     endif()
  46. endif()
  47.  
  48. target_link_libraries(Test_aplication PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
  49.  
  50. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
  51. # If you are developing for iOS or macOS you should consider setting an
  52. # explicit, fixed bundle identifier manually though.
  53. if(${QT_VERSION} VERSION_LESS 6.1.0)
  54.   set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Test_aplication)
  55. endif()
  56. set_target_properties(Test_aplication PROPERTIES
  57.     ${BUNDLE_ID_OPTION}
  58.     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
  59.     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
  60.     MACOSX_BUNDLE TRUE
  61.     WIN32_EXECUTABLE TRUE
  62. )
  63.  
  64. include(GNUInstallDirs)
  65. install(TARGETS Test_aplication
  66.     BUNDLE DESTINATION .
  67.     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  68.     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  69. )
  70.  
  71. if(QT_VERSION_MAJOR EQUAL 6)
  72.     qt_finalize_executable(Test_aplication)
  73. endif()
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement