-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
129 lines (112 loc) · 5.44 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
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
project(SFP-Master LANGUAGES C CXX)
# Set the CMAKE_INSTALL_PREFIX to /usr if not specified
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "The default install prefix on macOS" FORCE)
# Set Qt5 path for macOS
set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}/opt/qt@5" CACHE PATH "Path to Qt5 on macOS" FORCE)
else()
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
endif()
endif()
# Set the CMAKE_INSTALL_BINDIR to /bin if not specified
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
endif()
# Set the CMAKE_INSTALL_DATAROOTDIR to /share if not specified
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
endif()
# Set the CMAKE_INSTALL_LIBDIR to /lib if not specified
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "/lib" CACHE PATH "read-only single-machine data (lib)")
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt5Widgets REQUIRED)
find_package(LibUSB REQUIRED)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(UDEVDIR "/usr/lib/udev")
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr" OR CMAKE_INSTALL_PREFIX STREQUAL "/" )
# /usr and / install prefixes at treated by cmake GNUInstallDirs as
# synonym for "system location". In this case we can look up the correct udevdir
# using pkg-config.
# See: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#special-cases
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules( PKGCONFIG_UDEV udev)
if (PKGCONFIG_UDEV_FOUND)
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=udevdir udev
OUTPUT_VARIABLE PKGCONFIG_UDEVDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(PKGCONFIG_UDEVDIR)
file(TO_CMAKE_PATH "${PKGCONFIG_UDEVDIR}" UDEVDIR)
endif()
endif()
endif()
endif()
endif()
# Qt5LinguistTools
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)
# Translation files
set(TS_FILES
language/SFP-Master_hu_HU.ts
language/SFP-Master_ru_RU.ts
language/SFP-Master_it_IT.ts
language/SFP-Master_pt_BR.ts
)
qt5_add_translation(QM_FILES ${TS_FILES})
add_custom_target(translations DEPENDS ${QM_FILES})
add_executable(${PROJECT_NAME}
main.cpp
mainwindow.cpp
qhexedit.cpp
chunks.cpp
commands.cpp
dialogabout.cpp
dialogpass.cpp
ch341funcs.c
mainwindow.h
qhexedit.h
chunks.h
commands.h
dialogpass.h
ch341eeprom.h
dialogabout.h
mainwindow.ui
resource.qrc
${QM_FILES}
)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LibUSB_LIBRARIES})
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/SFP-Master.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/SFP-Master.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/SFP-Master.1.gz" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/man/man1")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/io.github.bigbigmdm.sfp-master.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/index.html" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/screenshot.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/my_sfp_adapter_sch.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/my_sfp_adapter_3d.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/connection.jpg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/undo64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/redo64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/read64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/write64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/password64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/save64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/open64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/exit64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/sfp-master/html")
install(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/sfp-master")
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/70-CH341.rules" DESTINATION "${UDEVDIR}/rules.d")
endif()