-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
112 lines (97 loc) · 2.39 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
cmake_minimum_required(VERSION 3.9)
# Project description
project(
kbbi-gtk
VERSION 1.0.0
DESCRIPTION "KBBI Offline with GTK3"
)
# Check required package & libraries
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT2GTK4 REQUIRED webkit2gtk-4.0)
pkg_check_modules(LIBKBBI REQUIRED libkbbi)
# Set C standard
set(CMAKE_C_STANDARD 99)
# Targets
add_executable(
${PROJECT_NAME}
src/main.c
src/ui.c
)
# Properties
set_target_properties(
${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
)
# Includes
target_include_directories(
${PROJECT_NAME}
PRIVATE src
)
# Link required libraries
target_link_libraries(
${PROJECT_NAME}
${GTK3_LIBRARIES}
${WEBKIT2GTK4_LIBRARIES}
${LIBKBBI_LIBRARIES}
)
# Include library's public header directory
target_include_directories(
${PROJECT_NAME}
PUBLIC ${GTK_INCLUDE_DIRS}
PUBLIC ${WEBKIT2GTK4_INCLUDE_DIRS}
PUBLIC ${LIBKBBI_INCLUDE_DIRS}
)
# Add library's extra compiler flags
target_compile_options(
${PROJECT_NAME}
PUBLIC ${GTK3_CLFAGS_OTHER}
PUBLIC ${WEBKIT2GTK4_CLFAGS_OTHER}
PUBLIC ${LIBKBBI_CLFAGS_OTHER}
)
# CMake setup
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_C_FLAGS "-Wall -Wextra -fvisibility=hidden")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(DESKTOP_PATH "share/applications/")
set(DESKTOP_ICON_PATH "share/icons/hicolor/128x128/apps")
set(DESKTOP_NAME "KBBI Offline")
set(DESKTOP_EXEC ${PROJECT_NAME})
set(DESKTOP_ICON_REF "${CMAKE_INSTALL_PREFIX}/${DESKTOP_ICON_PATH}/${PROJECT_NAME}.png")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/application.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/icon.png"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.png"
COPYONLY
)
# Install the file
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop
DESTINATION ${DESKTOP_PATH}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.png
DESTINATION ${DESKTOP_ICON_PATH}
)
# Expand uninstall script
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY
)
# Add uninstall target
add_custom_target(
uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake
)