代码拉取完成,页面将自动刷新
cmake_minimum_required(VERSION 3.5)
project(notepad 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)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets PrintSupport)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport)
#遍历所有Cpp、头文件、qrc文件、ui文件
file(GLOB_RECURSE CPP_FILES *.cpp *.h *.qrc *.ui)
foreach(filepath ${CPP_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND sources_files ${filename})
message(${filename})
endforeach(filepath)
set(PROJECT_SOURCES
${sources_files}
)
message("CMAKE_SOURCE_DIR")
message(${CMAKE_SOURCE_DIR})
find_package(Qt6 COMPONENTS Core LinguistTools REQUIRED)
set(TRANSLATIONS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/i18n")
qt_create_translation(QM_FILES
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/i18n/zh_CN.ts
OPTIONS -source-language "en_US" -target-language "zh_CN"
)
add_custom_target(copy_translations ALL
COMMAND ${CMAKE_COMMAND} -E copy ${QM_FILES} ${TRANSLATIONS_DIR}
DEPENDS ${QM_FILES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(notepad
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET notepad APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(notepad SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(notepad
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(notepad PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport)
set_target_properties(notepad PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS notepad
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(notepad)
endif()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。