-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
141 lines (110 loc) · 3.57 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 3.16)
project(GPT_Translator VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON) # Meta-Object Compiler
set(CMAKE_AUTORCC ON) # Resource Compiler
set(CMAKE_AUTOUIC ON) # User Interface Compiler
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DAPP_VERSION="${APP_VERSION}")
message(STATUS "APP_VERSION: ${APP_VERSION}")
if(NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "/Users/jg/Qt6/6.5.0/macos/lib/cmake/")
endif()
find_package(Qt6 REQUIRED COMPONENTS Quick TextToSpeech)
if(Qt6_VERSION_MAJOR EQUAL 6 AND Qt6_VERSION_MINOR GREATER_EQUAL 5)
qt6_policy(SET QTP0001 OLD)
endif()
set(HEADERS
src/controller.h
src/stdafx.h
src/updater.h
src/hotkey.h
)
set(SOURCES
src/main.cpp
src/controller.cpp
src/updater.cpp
src/hotkey.cpp
)
set(RESOURCES
GPT_Translator.qrc
)
add_subdirectory(lib/)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE(STATUS "current platform: Linux ")
find_package(X11 REQUIRED)
qt_add_executable(GPT_Translator
${SOURCES} ${HEADERS} ${RESOURCES}
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
MESSAGE(STATUS "current platform: Windows")
# set(CMAKE_EXE_LINKER_FLAGS "-static") use target_link_libraries instead
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/res/logo/logo.rc")
qt_add_executable(GPT_Translator ${app_icon_resource_windows}
${SOURCES} ${HEADERS} ${RESOURCES}
)
set_target_properties(GPT_Translator PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER tinyx.me
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
MESSAGE(STATUS "current platform: Darwin")
find_library( APP_SERVICES_LIBRARY ApplicationServices )
set(MACOSX_BUNDLE_ICON_FILE logo.icns)
# And the following tells CMake where to find and install the file itself.
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/res/logo/logo.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
qt_add_executable(GPT_Translator MACOSX_BUNDLE ${app_icon_macos}
${SOURCES} ${HEADERS} ${RESOURCES}
)
set_target_properties(GPT_Translator PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER tinyx.me
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
ENDIF()
include_directories("src")
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
if(DEFINED IS_MINGW)
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
user32
)
else()
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
user32
)
endif()
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_include_directories(GPT_Translator PRIVATE ${X11_INCLUDE_DIR})
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
${X11_LIBRARIES}
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_link_libraries(GPT_Translator
PRIVATE
Qt6::Quick
Qt6::TextToSpeech
qhotkey
${APP_SERVICES_LIBRARY}
)
ENDIF()
install(TARGETS GPT_Translator
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})