1 Star 1 Fork 1

Provence/notepad

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
Provence 提交于 2023-07-11 17:52 . 第一次提交
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/wang-honghust/notepad.git
git@gitee.com:wang-honghust/notepad.git
wang-honghust
notepad
notepad
master

搜索帮助