#======================= REFERENCE =======================# # reference: https://raw.githubusercontent.com/Andrew9317/qt-cmake-template/main/CMakeLists.txt #======================= Cmake Setup for Qt =======================# # set minimum version of cmake to work with. cmake_minimum_required(VERSION 3.16) # set cmake policies. # cmake_policy (SET CMP0015 NEW) # cmake_policy (SET CMP0016 NEW) # set cmake Project name. set (TARGET_NAME focus) # enables detailed output of every command cmake executes. set (CMAKE_VERBOSE_MAKEFILE ON) # enable AUTOMOC for CMake to take care of moc (Meta Object Compiler) for us. set (CMAKE_AUTOMOC ON) # enable AUTORCC for CMake to take care of rcc (Resource Compiler) for us. set (CMAKE_AUTORCC ON) # enable AUTOUIC for CMake to take care of UIC (User Interface Compiler) for us. set (CMAKE_AUTOUIC ON) # set the CXX standard, Qt 6 I believe uses c++ 17 set (CMAKE_CXX_STANDARD 14) set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_EXTENSIONS ON) # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") # setting up project properties project ( ${TARGET_NAME} VERSION 1.0 DESCRIPTION "App" LANGUAGES CXX ) # setting up paths and variables for QT 6.2.4 LTS set (QT_MAJOR_VERSION 6) set (QT_VERSION 6.2.4) set (Qt6_HOME "/Users/inkfil/Qt/6.2.4/ios/lib/cmake/Qt6") set (Qt6_DIR "/Users/inkfil/Qt/6.2.4/ios/lib/cmake/Qt6") set (QT6_BASE_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake/Qt${QT_MAJOR_VERSION}/") set (Qt6_CMAKE_DIR "/Users/inkfil/Qt/6.2.4/ios/lib/cmake") list(APPEND CMAKE_PREFIX_PATH "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake") set (Qt6BundledPcre2_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/cmake/Qt6BundledPcre2") set (Qt6CoreTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6CoreTools") set (Qt6WidgetsTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6WidgetsTools") set (Qt6QmlTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6QmlTools") set (Qt6GuiTools_DIR "/Users/inkfil/Qt/${QT_VERSION}/macos/lib/cmake/Qt6GuiTools") # command line compiler flag to enable/dissable bitcode # list(APPEND CMAKE_CXX_FLAGS " -fembed-bitcode") # set_target_properties(${TARGET_NAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE NO) #======================= set xcode signing/provisioninf and archiving options =======================# set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "") set(CMAKE_OSX_SYSROOT iphoneos) set (CMAKE_OSX_DEPLOYMENT_TARGET 11.0) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Distribution") # "iPhone Developer") set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "") set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM **********) # Find qt components for IOS. find_package ( Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core OpenGL Widgets Multimedia Network Sql Quick QuickWidgets Svg WebView Core5Compat ) # cmake command to generate an executable target. qt_add_executable ( ${TARGET_NAME} MACOSX_BUNDLE ${QML_SOURCE} ${QRC_FILES} ${QUIVER_SOURCE} ${IMAGES_FOCUS_APP} ${APP_COMMON_HEADERS} ${APP_COMMON_SOURCES} ${OBJECTIVE_HEADERS} ${OBJECTIVE_SOURCES} ) #======================= enable build options =======================# set_target_properties (${TARGET_NAME} PROPERTIES DEBUG_OUTPUT_NAME "${TARGET_NAME}d" RELEASE_OUTPUT_NAME ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "com.org.app" MACOSX_BUNDLE_INFO_PLIST "/Users/inkfil/AppSource/info.plist" MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "my_provisioning_profile" XCODE_ATTRIBUTE_BUNDLE_PACKAGE_TYPE "APPL" MACOSX_BUNDLE_ICON_FILE "/Users/inkfil/AppSource/App.ico" MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) # Find boost components for IOS add_library(boost STATIC IMPORTED) # or STATIC instead of SHARED set_target_properties(boost PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/lib/libboost.a" INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/include/" ) #[[ List all libs from qt to link from qt installation dir. ]] # file(GLOB QT_LIB_FILES "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/*.a") set (QT_LIB_DIR "/Users/inkfil/Qt/${QT_VERSION}/ios/lib/" PATH) #[[ List all libs from local dir to link. ]] # file(GLOB LOCAL_LIB_FILES "lib/ios/*.a") set (LOCAL_LIB_DIR "lib/ios/" PATH) link_directories ( QT_LIB_DIR LOCAL_LIB_DIR "/Users/inkfil/Qt/6.2.4/ios/plugins/platforms" ) # Enable compiler options based on the compiler. if(MSVC) target_compile_options (${TARGET_NAME} PRIVATE /W4 /WX) else() # Target_compile_options (${TARGET_NAME} PRIVATE -O2 -v) # -Wall -Wextra -pedantic -Werror) # Link_options ("LINKER:-z,defs") endif() #======================= link Qt packages =======================# # Add qt and boost components to link to target. # set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-Wl,-e,_qt_main_wrapper") target_link_libraries ( ${TARGET_NAME} PRIVATE #[[ Link ios frameworks located at iphoneos.sdk path. ]] "-lm" "-framework OpenGLES" "-framework Network" "-framework NetworkExtension" "-framework PDFKit" "-framework WidgetKit" "-framework CryptoKit" "-framework MessageUI" "-framework Security" "-framework IntentsUI" "-framework IOKit" "-framework AVFoundation" "-framework CoreAudio" "-framework AssetsLibrary" "-lz" "-framework MobileCoreServices" "-lm" "-framework UIKit" "-framework ExternalAccessory" "-framework VideoToolbox" "-framework CoreMedia" "-framework CoreVideo" "-framework ImageIO" "-framework CoreFoundation" "-framework Foundation" "-framework CoreText" "-framework CoreGraphics" "-framework WebKit" "-framework QuartzCore" "-framework AudioToolbox" #[[ Including headers for qt components and Link qt components. ]] Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Widgets Qt${QT_MAJOR_VERSION}::OpenGL Qt${QT_MAJOR_VERSION}::Multimedia Qt${QT_MAJOR_VERSION}::Network Qt${QT_MAJOR_VERSION}::Sql Qt${QT_MAJOR_VERSION}::Quick Qt${QT_MAJOR_VERSION}::QuickWidgets Qt${QT_MAJOR_VERSION}::Svg Qt${QT_MAJOR_VERSION}::WebView Qt${QT_MAJOR_VERSION}::Core5Compat #[[ Link boost lib components build from source using following commands: ]] boost #[[ Adds all libs from local dir, causes 1. Duplicate symbol error. 2. Building for iOS-arm64 but attempting to link with file built for macOS-x86_64. ]] ${QT_LIB_FILES} #[[ Adds all libs from local dir, causes 1. Duplicate symbol error. 2. Building for iOS-arm64 but attempting to link with file built for macOS-x86_64. ]] ${LOCAL_LIB_FILES} #[[ Solves following error. "_uncompress", referenced from: qUncompress(unsigned char const*, int) in libQt5Core.a(qbytearray.o) ]] "-lz" #[[ https://stackoverflow.com/questions/45508043/qt-ios-linker-error-entry-point-main-undefined ]] #"-Wl,-e,_qt_main_wrapper" #"-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" "-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" "-lstdc++" )