cmake_minimum_required(VERSION 3.20) project(%1 VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/debug) else() set(APPLICATION_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/release) endif() if(APPLE) set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/MacOS) else() set(APPLICATION_REAL_PATH ${APPLICATION_OUTPUT_DIRECTORY}) endif() find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick) find_program(QT_LUPDATE NAMES lupdate) find_program(QT_LRELEASE NAMES lrelease) if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_en_US.qm) execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_en_US.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif () if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}_zh_CN.qm) execute_process(COMMAND ${QT_LUPDATE} ${CMAKE_CURRENT_LIST_DIR} -ts ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) execute_process(COMMAND ${QT_LRELEASE} ${PROJECT_NAME}_zh_CN.ts WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif () file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm) file(COPY ${QM_FILE_PATHS} DESTINATION ${APPLICATION_REAL_PATH}/i18n) set(PROJECT_SOURCES main.cpp qml.qrc ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION ${PROJECT_SOURCES} ) else() add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ) endif() set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${APPLICATION_OUTPUT_DIRECTORY}" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${APPLICATION_OUTPUT_DIRECTORY}" ) target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick fluentuiplugin ) if(${QT_VERSION} VERSION_LESS 6.1.0) set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.${PROJECT_NAME}) endif() set_target_properties(${PROJECT_NAME} PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) add_subdirectory(FluentUI) include(GNUInstallDirs) install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(QT_VERSION_MAJOR EQUAL 6) qt_import_qml_plugins(${PROJECT_NAME}) qt_finalize_executable(${PROJECT_NAME}) endif()