cmake_minimum_required(VERSION 3.14) project(untitled4 VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) # TODO: Move macro to better location # This macro sets the correct target properties by appending $(EFFECTIVE_PLATFORM_NAME) # for libraries built with XCode. It will correct `build/Debug/libuntitled4.a' to # `build/Debug-iphoneos/libuntitled4.a' macro(ios_fix_lib_build_folder TARGET) if(IOS AND XCODE) set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") endif() endmacro() # QtCreator supports the following variables for Android, which are identical to qmake Android variables. # Check https://doc.qt.io/qt/deployment-android.html for more information. # They need to be set before the find_package(...) calls below. #if(ANDROID) # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") # if (ANDROID_ABI STREQUAL "armeabi-v7a") # set(ANDROID_EXTRA_LIBS # ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so # ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so) # endif() #endif() find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED) if(IOS) find_package(Qt6 REQUIRED QmlImportScanner) endif() set(PROJECT_SOURCES main.cpp qml.qrc ) # Create untitled4 library add_library(untitled4 STATIC ${PROJECT_SOURCES}) ios_fix_lib_build_folder(untitled4) target_compile_definitions(untitled4 PRIVATE $<$,$>:QT_QML_DEBUG>) target_link_libraries(untitled4 PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick) qt_add_executable(untitled4Standalone MANUAL_FINALIZATION empty_file ) set_target_properties(untitled4Standalone PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) target_compile_definitions(untitled4Standalone PRIVATE $<$,$>:QT_QML_DEBUG>) target_link_libraries(untitled4Standalone PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick) qt_import_qml_plugins(untitled4Standalone) qt_finalize_executable(untitled4Standalone) target_link_libraries(untitled4Standalone PRIVATE untitled4)