-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
108 lines (90 loc) · 3.66 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
cmake_minimum_required(VERSION 3.5)
project(OneMarkdown 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)
# 设置 Qt 库的地址(按需设置)
# set(QT_PATH "D:\\ProgramData\\Qt\\Qt5.12.12\\5.12.12\\mingw73_64")
set(QT_PATH "D:\\ProgramData\\Qt\\Qt5.12.12\\5.12.12\\msvc2017_64")
# set(QT_PATH "D:\\programs\\Qt\\Qt5.12.12\\5.12.12\\msvc2017_64")
set(CMAKE_PREFIX_PATH ${QT_PATH}/lib/cmake)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets WebEngineWidgets WebChannel REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools REQUIRED)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(TS_FILES OneMarkdown_zh_CN.ts)
file(GLOB_RECURSE QRC_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/*.qrc)
qt5_add_resources(qrc_FILES data/img.qrc)
set(PROJECT_SOURCES
src/main.cpp
src/OneMarkdown.cpp
src/OneMarkdown.h
src/OneMarkdown.ui
src/file.h
src/file.cpp
src/common.h
src/common.cpp
src/menu.cpp
src/global.cpp
${TS_FILES}
${qrc_FILES}
)
if(MATRIX_BUILD AND NOT MATRIX_SUBBUILD AND NOT QT_SUPERBUILD)
add_build(webengine_webrtc OFF)
add_build(webengine_proprietary_codecs ON)
add_build(webengine_printing_and_pdf OFF)
add_build(webengine_extensions OFF)
add_build(webengine_spellchecker OFF)
add_build(qtwebengine_build OFF)
return()
endif()
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(OneMarkdown
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET OneMarkdown 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
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
if(ANDROID)
add_library(OneMarkdown 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(OneMarkdown
${PROJECT_SOURCES}
)
endif()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
target_link_libraries(OneMarkdown PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(OneMarkdown PRIVATE Qt${QT_VERSION_MAJOR}::WebEngineWidgets Qt${QT_VERSION_MAJOR}::WebChannel)
set_target_properties(OneMarkdown 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}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(OneMarkdown)
endif()
# ------------------------------------------------------------------------------
if(${MADDY_BUILD_WITH_TESTS})
add_subdirectory(tests)
endif()
# ------------------------------------------------------------------------------
if(${MADDY_CREATE_PACKAGE})
set(MADDY_PACKAGE_FILES include/ CMakeLists.txt LICENSE)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${MADDY_PACKAGE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${MADDY_PACKAGE_FILES})
add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip)
endif()