forked from Bollos00/LibreMines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
210 lines (189 loc) · 8.73 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#############################################################################
# LibreMines #
# Copyright (C) 2020-2024 Bruno Bollos Correa # #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#############################################################################
message(STATUS "Using CMake version ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 3.1.0)
project(libremines
VERSION "2.0.1"
DESCRIPTION " A Free/Libre and Open Source Software Qt based Minesweeper game available for GNU/Linux, FreeBSD and Windows systems. "
HOMEPAGE_URL "https://github.com/Bollos00/LibreMines"
LANGUAGES "CXX"
)
option(USE_QT6 "Wheter to use Qt5 or Qt6 libraries" TRUE)
option(UPDATE_TRANSLATIONS "Generate de QM translation files" FALSE)
option(INSTALL_EXTRA_MINEFIELD_THEMES "Install extra thmes for the minefield" TRUE)
option(INSTALL_EXTRA_FACESREACTION_THEMES "Install extra thmes for the faces reaction" TRUE)
# Add the Qt dependencies according to the option `USE_QT6`
if(USE_QT6)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Svg)
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
# If the option UPDATE_TRANSLATIONS is passed, the Qt5LinguistTools is needed
# to generate the QM Files
if(UPDATE_TRANSLATIONS)
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
endif()
else()
find_package(Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt5 REQUIRED COMPONENTS Core)
find_package(Qt5 REQUIRED COMPONENTS Svg)
find_package(Qt5 REQUIRED COMPONENTS Multimedia)
if(UPDATE_TRANSLATIONS)
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)
endif()
endif()
# Save the variables of the project (see file `include/cmake/libreminesconfig.h.in`) on
# the file ${PROJECT_BINARY_DIR}/libreminesconfig.h
configure_file(${PROJECT_SOURCE_DIR}/include/libreminesconfig.h.in ${PROJECT_BINARY_DIR}/libreminesconfig.h)
# Create the translation files (QM File Format) from the ts files
if(UPDATE_TRANSLATIONS)
set(TS_FILES
etc/translations/${PROJECT_NAME}_es.ts
etc/translations/${PROJECT_NAME}_pt_BR.ts
)
# Put the QM Files on `etc/translations`
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/etc/translations)
if(USE_QT6)
qt6_add_translation(QM_FILES ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
endif()
endif()
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "Using default build type Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html
string(COMPARE EQUAL "${CMAKE_CXX_STANDARD}" "" no_cmake_cxx_standard_set)
if(no_cmake_cxx_standard_set)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "Using default C++ standard ${CMAKE_CXX_STANDARD}")
else()
message(STATUS "Using user specified C++ standard ${CMAKE_CXX_STANDARD}")
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
add_executable(${PROJECT_NAME} WIN32
etc/translations/libremines_translations_qm.qrc
src/common.h
src/extrathemes.cpp src/extrathemes.h
src/main.cpp
src/facesreaction.h src/facesreaction.cpp
src/keyboardcontroller.h src/keyboardcontroller.cpp
src/libreminesapptheme.cpp src/libreminesapptheme.h
src/libreminesgameengine.cpp src/libreminesgameengine.h
src/libreminesgui.cpp src/libreminesgui.h
src/libreminespreferencesdialog.cpp src/libreminespreferencesdialog.h src/libreminespreferencesdialog.ui
src/libreminespreferencessaver.cpp src/libreminespreferencessaver.h
src/libreminesscore.cpp src/libreminesscore.h
src/libreminesscoresdialog.cpp src/libreminesscoresdialog.h
src/libreminesviewscoresdialog.cpp src/libreminesviewscoresdialog.h
src/minefieldtheme.cpp src/minefieldtheme.h
src/qkeyinput.cpp src/qkeyinput.h
src/qlabel_adapted.cpp src/qlabel_adapted.h
src/qpushbutton_adapted.cpp src/qpushbutton_adapted.h
src/soundeffects.cpp src/soundeffects.h
share/facesreaction.qrc
share/icons.qrc
share/icons.rc
share/minefield_themes.qrc
share/sound_effects.qrc
)
include_directories(src)
include_directories(include)
include_directories(${PROJECT_BINARY_DIR})
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
target_compile_definitions(${PROJECT_NAME} PRIVATE QT_DEPRECATED_WARNINGS)
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#target_compile_definitions(${PROJECT_NAME} PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0x060000)
# disables all the APIs deprecated before Qt 6.0.0
# Link the Qt dependencies according to the option `USE_QT6`
if(USE_QT6)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Svg)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Multimedia)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Svg)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Multimedia)
endif()
# Set the install settings for Unix environments
if(UNIX)
# create install target
include(GNUInstallDirs)
# Install the executable
install(
TARGETS
${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# Install the desktop entry and the icon
install(FILES share/desktop_entry/libremines.desktop DESTINATION share/applications)
install(FILES share/icons/libremines.svg DESTINATION share/icons/hicolor/scalable/apps)
# Install the extra minefield themes on
# ${CMAKE_INSTALL_PREFIX}/share/libremines/minefield_extra_themes
if(INSTALL_EXTRA_MINEFIELD_THEMES)
install(
DIRECTORY share/minefield_themes/alternative_light
DESTINATION share/libremines/minefield_extra_themes
)
install(
DIRECTORY share/minefield_themes/alternative_dark
DESTINATION share/libremines/minefield_extra_themes
)
install(
DIRECTORY share/minefield_themes/flowerfield
DESTINATION share/libremines/minefield_extra_themes
)
install(
DIRECTORY share/minefield_themes/twemoji
DESTINATION share/libremines/minefield_extra_themes
)
endif()
if(INSTALL_EXTRA_FACESREACTION_THEMES)
install(
DIRECTORY share/faces_reaction/open-emoji-black
DESTINATION share/libremines/facesreaction_extra_themes
)
install(
DIRECTORY share/faces_reaction/open-emoji-white
DESTINATION share/libremines/facesreaction_extra_themes
)
install(
DIRECTORY share/faces_reaction/twemoji-color
DESTINATION share/libremines/facesreaction_extra_themes
)
install(
DIRECTORY share/faces_reaction/SecularSteve_custom
DESTINATION share/libremines/facesreaction_extra_themes
)
endif()
elseif(WIN32)
endif()