Advertisement
Guest User

Untitled

a guest
Dec 7th, 2022
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 9.47 KB | Source Code | 0 0
  1.  
  2. #======================= REFERENCE =======================#
  3. # reference:  https://raw.githubusercontent.com/Andrew9317/qt-cmake-template/main/CMakeLists.txt
  4.  
  5. #======================= Cmake Setup for Qt =======================#
  6. # set minimum version of cmake to work with.
  7. cmake_minimum_required(VERSION 3.16)
  8.  
  9. # set cmake policies.
  10. # cmake_policy (SET CMP0015 NEW)
  11. # cmake_policy (SET CMP0016 NEW)
  12.  
  13. # set cmake Project name.
  14. set (TARGET_NAME focus)
  15.  
  16. # enables detailed output of every command cmake executes.
  17. set (CMAKE_VERBOSE_MAKEFILE ON)
  18.  
  19. # enable AUTOMOC for CMake to take care of moc (Meta Object Compiler) for us.
  20. set (CMAKE_AUTOMOC ON)
  21.  
  22. # enable AUTORCC for CMake to take care of rcc (Resource Compiler) for us.
  23. set (CMAKE_AUTORCC ON)
  24.  
  25. # enable AUTOUIC for CMake to take care of UIC (User Interface Compiler) for us.
  26. set (CMAKE_AUTOUIC ON)
  27.  
  28. # set the CXX standard, Qt 6 I believe uses c++ 17
  29. set (CMAKE_CXX_STANDARD 14)
  30. set (CMAKE_CXX_STANDARD_REQUIRED ON)
  31. set (CMAKE_CXX_EXTENSIONS ON)
  32. # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
  33.  
  34. # setting up project properties
  35. project (
  36.     ${TARGET_NAME}
  37.     VERSION 1.0
  38.     DESCRIPTION "App"
  39.     LANGUAGES CXX
  40. )
  41.  
  42. # setting up paths and variables for QT 6.2.4 LTS
  43.  
  44. set (QT_MAJOR_VERSION 6)
  45. set (QT_VERSION 6.2.4)
  46. set (Qt6_HOME "/Users/inkfil/Qt/6.2.4/ios/lib/cmake/Qt6")
  47. set (Qt6_DIR "/Users/inkfil/Qt/6.2.4/ios/lib/cmake/Qt6")
  48. set (QT6_BASE_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake/Qt${QT_MAJOR_VERSION}/")
  49. set (Qt6_CMAKE_DIR "/Users/inkfil/Qt/6.2.4/ios/lib/cmake")
  50. list(APPEND CMAKE_PREFIX_PATH "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake")
  51.  
  52. set (Qt6BundledPcre2_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake/Qt6BundledPcre2")
  53. set (Qt6CoreTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6CoreTools")
  54. set (Qt6WidgetsTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6WidgetsTools")
  55. set (Qt6QmlTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6QmlTools")
  56. set (Qt6GuiTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6GuiTools")
  57.  
  58. # command line compiler flag to enable/dissable bitcode
  59. # list(APPEND CMAKE_CXX_FLAGS " -fembed-bitcode")
  60. # set_target_properties(${TARGET_NAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE NO)
  61.  
  62. #======================= set xcode signing/provisioninf and archiving options =======================#
  63. set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
  64. set(CMAKE_OSX_SYSROOT iphoneos)
  65. set (CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
  66. set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Distribution") # "iPhone Developer")
  67. set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "")
  68. set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM **********)
  69.  
  70. # Find qt components for IOS.
  71. find_package (
  72.     Qt${QT_MAJOR_VERSION}
  73.     REQUIRED COMPONENTS Core OpenGL Widgets Multimedia Network Sql Quick QuickWidgets Svg WebView Core5Compat
  74. )
  75.  
  76. # cmake command to generate an executable target.
  77. qt_add_executable (
  78.     ${TARGET_NAME}
  79.     MACOSX_BUNDLE
  80.     ${QML_SOURCE}
  81.     ${QRC_FILES}
  82.     ${QUIVER_SOURCE}
  83.     ${IMAGES_FOCUS_APP}
  84.     ${APP_COMMON_HEADERS}
  85.     ${APP_COMMON_SOURCES}
  86.     ${OBJECTIVE_HEADERS}
  87.     ${OBJECTIVE_SOURCES}
  88. )
  89. #======================= enable build options =======================#
  90.  
  91. set_target_properties (${TARGET_NAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}d" RELEASE_OUTPUT_NAME ${TARGET_NAME})
  92. set_target_properties(${TARGET_NAME} PROPERTIES
  93.     MACOSX_BUNDLE_GUI_IDENTIFIER "com.org.app"
  94.     MACOSX_BUNDLE_INFO_PLIST "/Users/inkfil/AppSource/info.plist"
  95.     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
  96.     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
  97.     MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
  98.     XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "my_provisioning_profile"
  99.     XCODE_ATTRIBUTE_BUNDLE_PACKAGE_TYPE "APPL"
  100.     MACOSX_BUNDLE_ICON_FILE "/Users/inkfil/AppSource/App.ico"
  101.     MACOSX_BUNDLE TRUE
  102.     WIN32_EXECUTABLE TRUE
  103. )
  104.  
  105. # Find boost components for IOS
  106. add_library(boost STATIC IMPORTED) # or STATIC instead of SHARED
  107. set_target_properties(boost PROPERTIES
  108.   IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/lib/libboost.a"
  109.   INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/include/"
  110. )
  111.  
  112. #[[
  113.     List all libs from qt to link from qt installation dir.
  114. ]]
  115. # file(GLOB QT_LIB_FILES "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/*.a")
  116. set (QT_LIB_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/" PATH)
  117.  
  118. #[[
  119.     List all libs from local dir to link.
  120. ]]
  121. # file(GLOB LOCAL_LIB_FILES "lib/ios/*.a")
  122. set (LOCAL_LIB_DIR "lib/ios/" PATH)
  123.  
  124. link_directories (
  125.     QT_LIB_DIR
  126.     LOCAL_LIB_DIR
  127.     "/Users/inkfil/Qt/6.2.4/ios/plugins/platforms"
  128. )
  129.  
  130. # Enable compiler options based on the compiler.
  131. if(MSVC)
  132.     target_compile_options (${TARGET_NAME} PRIVATE /W4 /WX)
  133. else()
  134.     # Target_compile_options (${TARGET_NAME} PRIVATE -O2 -v) # -Wall -Wextra -pedantic -Werror)
  135.     # Link_options ("LINKER:-z,defs")
  136. endif()
  137.  
  138. #======================= link Qt packages =======================#
  139.  
  140. # Add qt and boost components to link to target.
  141. # set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-Wl,-e,_qt_main_wrapper")
  142.  
  143. target_link_libraries (
  144.     ${TARGET_NAME}
  145.  
  146.     PRIVATE
  147.     #[[
  148.         Link ios frameworks located at iphoneos.sdk path.
  149.     ]]
  150.     "-lm"
  151.     "-framework OpenGLES"
  152.     "-framework Network"
  153.     "-framework NetworkExtension"
  154.     "-framework PDFKit"
  155.     "-framework WidgetKit"
  156.     "-framework CryptoKit"
  157.     "-framework MessageUI"
  158.     "-framework Security"
  159.     "-framework IntentsUI"
  160.     "-framework IOKit"
  161.     "-framework AVFoundation"
  162.     "-framework CoreAudio"
  163.     "-framework AssetsLibrary"
  164.     "-lz"
  165.     "-framework MobileCoreServices"
  166.     "-lm"
  167.     "-framework UIKit"
  168.     "-framework ExternalAccessory"
  169.     "-framework VideoToolbox"
  170.     "-framework CoreMedia"
  171.     "-framework CoreVideo"
  172.     "-framework ImageIO"
  173.     "-framework CoreFoundation"
  174.     "-framework Foundation"
  175.     "-framework CoreText"
  176.     "-framework CoreGraphics"
  177.     "-framework WebKit"
  178.     "-framework QuartzCore"
  179.     "-framework AudioToolbox"
  180.  
  181.     #[[
  182.         Including headers for qt components and Link qt components.
  183.     ]]
  184.     Qt${QT_MAJOR_VERSION}::Core
  185.     Qt${QT_MAJOR_VERSION}::Widgets
  186.     Qt${QT_MAJOR_VERSION}::OpenGL
  187.     Qt${QT_MAJOR_VERSION}::Multimedia
  188.     Qt${QT_MAJOR_VERSION}::Network
  189.     Qt${QT_MAJOR_VERSION}::Sql
  190.     Qt${QT_MAJOR_VERSION}::Quick
  191.     Qt${QT_MAJOR_VERSION}::QuickWidgets
  192.     Qt${QT_MAJOR_VERSION}::Svg
  193.     Qt${QT_MAJOR_VERSION}::WebView
  194.     Qt${QT_MAJOR_VERSION}::Core5Compat
  195.  
  196.     #[[
  197.         Link boost lib components build from source using following commands:
  198.  
  199.     ]]
  200.     boost
  201.  
  202.      #[[
  203.         Adds all libs from local dir, causes
  204.         1. Duplicate symbol error.
  205.         2. Building for iOS-arm64 but attempting to link with file built for macOS-x86_64.
  206.     ]]
  207.     ${QT_LIB_FILES}
  208.  
  209.     #[[
  210.         Adds all libs from local dir, causes
  211.         1. Duplicate symbol error.
  212.         2. Building for iOS-arm64 but attempting to link with file built for macOS-x86_64.
  213.     ]]
  214.     ${LOCAL_LIB_FILES}
  215.  
  216.     #[[
  217.         Solves following error.
  218.         "_uncompress", referenced from:
  219.       qUncompress(unsigned char const*, int) in libQt5Core.a(qbytearray.o)
  220.     ]]
  221.     "-lz"
  222.    
  223.     #[[
  224.         https://stackoverflow.com/questions/45508043/qt-ios-linker-error-entry-point-main-undefined
  225.     ]]
  226.     #"-Wl,-e,_qt_main_wrapper"
  227.  
  228.     #"-lqios_debug -lqavfcamera_debug -lqavfmediaplayer_debug -lQt5MultimediaWidgets_debug -lqtmedia_audioengine_debug -lqtaudio_coreaudio_debug -lqtmultimedia_m3u_debug -lqtwebview_darwin_debug -lQt5FontDatabaseSupport_debug -lqtfreetype_debug -lQt5GraphicsSupport_debug -lQt5ClipboardSupport_debug -lqsvgicon_debug -lqgif_debug -lqicns_debug -lqico_debug -lqjpeg_debug -lqmacheif_debug -lqmacjp2_debug -lqsvg_debug -lqtga_debug -lqtiff_debug -lqwbmp_debug -lqwebp_debug -lqsqlite_debug -lqmldbg_debugger_debug -lqmldbg_inspector_debug -lqmldbg_local_debug -lqmldbg_messages_debug -lqmldbg_native_debug -lqmldbg_nativedebugger_debug -lqmldbg_preview_debug -lqmldbg_profiler_debug -lqmldbg_quickprofiler_debug -lqmldbg_server_debug -lQt5PacketProtocol_debug -lqmldbg_tcp_debug -lqgenericbearer_debug -lQt5OpenGL_debug -lQt5Svg_debug -lQt5Sql_debug -lqtgraphicaleffectsprivate_debug -lqmltestplugin_debug -lQt5QuickTest_debug -lQt5Test_debug -lqtquickcontrols2plugin_debug -ldeclarative_webview_debug -lQt5WebView_debug -lqquicklayoutsplugin_debug -ldeclarative_multimedia_debug -lQt5MultimediaQuick_debug -lQt5Multimedia_debug -ldialogplugin_debug -lqmlfolderlistmodelplugin_debug -lqmlsettingsplugin_debug -ldialogsprivateplugin_debug -lqtquickcontrolsplugin_debug -lwidgetsplugin_debug -lQt5Widgets_debug -lqtquick2plugin_debug -lmodelsplugin_debug -lwindowplugin_debug -lqtquickcontrols2materialstyleplugin_debug -lqtquicktemplates2plugin_debug -lqtquickcontrols2fusionstyleplugin_debug -lqtquickcontrols2universalstyleplugin_debug -lqtquickcontrols2imaginestyleplugin_debug -lQt5QuickControls2_debug -lQt5QuickTemplates2_debug -lqtgraphicaleffectsplugin_debug -lQt5Quick_debug -lQt5Gui_debug -lqtlibpng_debug -lqtharfbuzz_debug -lQt5Qml_debug -lQt5Network_debug -lQt5Core_debug -lqtpcre2_debug"
  229.    
  230.     "-lRedSocket -lcrypto -lssl -lqsqlcipher -lscrypt -lQt-Secret -lQtBigInt -Xlinker -map -Xlinker /Users/inkfil/LinkMap/linkmapcmake.txt -dead_strip -Xlinker -no_deduplicate -fobjc-link-runtime -stdlib\=libc++ -Xlinker -no_adhoc_codesign -Xlinker -dependency_info"
  231.     "-lstdc++"
  232. )
  233.  
Tags: cmake
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement