Skip to content

Commit 636643f

Browse files
committed
Support cmake build system
Since AFAIK qmake won't be supported much longer use cmake instead. + build of translations + ccache/distcc detection + option to create a build with -fsanitize=address
1 parent e7c8f36 commit 636643f

File tree

1 file changed

+168
-0
lines changed

1 file changed

+168
-0
lines changed

CMakeLists.txt

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(phototonic LANGUAGES CXX VERSION 2.99.0)
4+
5+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
6+
7+
set(CMAKE_AUTOMOC ON)
8+
set(CMAKE_AUTOUIC ON)
9+
set(CMAKE_AUTORCC ON)
10+
11+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
12+
13+
set(CMAKE_CXX_STANDARD 17)
14+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
15+
16+
IF(MSVC)
17+
SET(OPTIONS WIN32)
18+
ENDIF(MSVC)
19+
20+
add_executable(${PROJECT_NAME} ${OPTIONS}
21+
ShortcutsTable.cpp
22+
ThumbsViewer.h
23+
Phototonic.cpp
24+
Bookmarks.cpp
25+
FileSystemTree.h
26+
MetadataCache.cpp
27+
SettingsDialog.h
28+
SmartCrop.cpp
29+
RenameDialog.h
30+
ResizeDialog.h
31+
ResizeDialog.cpp
32+
Phototonic.h
33+
ColorsDialog.cpp
34+
SettingsDialog.cpp
35+
ColorsDialog.h
36+
GuideWidget.cpp
37+
DirCompleter.h
38+
Bookmarks.h
39+
MessageBox.h
40+
ImageWidget.h
41+
InfoViewer.cpp
42+
CopyMoveDialog.h
43+
CopyMoveToDialog.cpp
44+
DirCompleter.cpp
45+
CropRubberband.h
46+
GuideWidget.h
47+
ImageViewer.cpp
48+
CopyMoveToDialog.h
49+
CropRubberband.cpp
50+
CropDialog.cpp
51+
Settings.cpp
52+
Tags.h
53+
CropDialog.h
54+
ExternalAppsDialog.cpp
55+
RenameDialog.cpp
56+
Tags.cpp
57+
ThumbsViewer.cpp
58+
FileSystemTree.cpp
59+
ExternalAppsDialog.h
60+
MetadataCache.h
61+
Settings.h
62+
ImageWidget.cpp
63+
ImageViewer.h
64+
MessageBox.cpp
65+
main.cpp
66+
IconProvider.h
67+
CopyMoveDialog.cpp
68+
SmartCrop.h
69+
InfoViewer.h
70+
ShortcutsTable.h
71+
IconProvider.cpp
72+
${TS_FILES}
73+
)
74+
75+
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
76+
77+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Widgets OpenGLWidgets LinguistTools)
78+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets OpenGLWidgets LinguistTools)
79+
80+
target_link_libraries(${PROJECT_NAME}
81+
PRIVATE
82+
Qt::OpenGLWidgets
83+
Qt::Widgets
84+
Qt::Core
85+
)
86+
87+
# translations
88+
set(TRANSLATION_FILES
89+
translations/phototonic.ts
90+
translations/phototonic_de.ts
91+
translations/phototonic_ka.ts
92+
translations/phototonic_it.ts
93+
translations/phototonic_sr.ts
94+
translations/phototonic_uk.ts
95+
translations/phototonic_cs.ts
96+
translations/phototonic_fr.ts
97+
translations/phototonic_es.ts
98+
translations/phototonic_et.ts
99+
translations/phototonic_zh.ts
100+
translations/phototonic_zh_TW.ts
101+
translations/phototonic_bs.ts
102+
translations/phototonic_nl.ts
103+
translations/phototonic_sv.ts
104+
translations/phototonic_fi.ts
105+
translations/phototonic_pt.ts
106+
translations/phototonic_pl.ts
107+
translations/phototonic_hr.ts
108+
translations/phototonic_ru.ts
109+
)
110+
111+
112+
set_source_files_properties(${TRANSLATION_FILES}
113+
PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
114+
115+
qt_add_translations(${PROJECT_NAME}
116+
TS_FILES ${TRANSLATION_FILES}
117+
)
118+
119+
# exiv2
120+
find_package(exiv2)
121+
target_link_libraries(${PROJECT_NAME} PRIVATE exiv2lib)
122+
123+
# installation
124+
include(GNUInstallDirs)
125+
install(TARGETS ${PROJECT_NAME}
126+
EXPORT ${PROJECT_NAME}-targets
127+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
128+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
129+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
130+
)
131+
132+
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
133+
install(FILES images/phototonic.png DESTINATION share/icons/hicolor/512x512/apps)
134+
135+
install(FILES images/phototonic.png DESTINATION share/icons/hicolor/48x48/apps)
136+
install(FILES images/icon16/phototonic.png DESTINATION share/icons/hicolor/16x16/apps)
137+
install(FILES images/icon16/phototonic.png DESTINATION share/pixmaps)
138+
139+
install(FILES phototonic.desktop DESTINATION share/applications)
140+
install(FILES phototonic.appdata.xml DESTINATION share/metainfo)
141+
142+
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
143+
144+
# Auto. CCACHE
145+
if(UNIX)
146+
find_program(CCACHE_FOUND ccache)
147+
148+
if(CCACHE_FOUND)
149+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
150+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
151+
endif(CCACHE_FOUND)
152+
endif()
153+
154+
# Auto. distcc
155+
if(UNIX)
156+
find_program(DISTCC_FOUND distcc)
157+
158+
if(DISTCC_FOUND)
159+
set(ENV{CCACHE_PREFIX} distcc)
160+
endif(DISTCC_FOUND)
161+
endif()
162+
163+
164+
option(USE_ASAN "Build with address sanitizer" OFF)
165+
if(USE_ASAN)
166+
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
167+
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
168+
endif()

0 commit comments

Comments
 (0)