forked from KDE/breeze-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
141 lines (116 loc) · 5.37 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)
set(KF_VERSION "5.98.0") # handled by release scripts
project(BreezeIcons VERSION ${KF_VERSION})
# Disallow in-source build
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Breeze Icons requires an out-of-source build. Please create a separate build directory and run 'cmake path_to_breeze_icons [options]' there.")
endif()
# ECM setup
include(FeatureSummary)
find_package(ECM 5.97.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEGitCommitHooks)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(GtkUpdateIconCache)
# Dependencies
set(REQUIRED_QT_VERSION 5.15.2)
# Find Python 3
find_package (Python 3 COMPONENTS Interpreter)
# FIXME: This is a temporary solution to unbreak KDE's Windows CI.
# Remove "NOT WIN32" when icon generation works on Windows.
if(Python_FOUND AND NOT WIN32)
# Find lxml Python 3 module
exec_program(${Python_EXECUTABLE}
ARGS "-c \"import lxml; from lxml import etree; print(lxml.get_include())\""
RETURN_VALUE LXML_NOT_FOUND # Returns 0 or false if successful
)
# Generating icons is not required, but strongly recommended in most cases
if(LXML_NOT_FOUND)
message(WARNING "lxml or lxml.etree not found; icon generation disabled")
set(WITH_ICON_GENERATION OFF)
else()
option(WITH_ICON_GENERATION "Icon generation" ON)
endif()
else()
set(WITH_ICON_GENERATION OFF)
endif()
add_feature_info("Icon generation" ${WITH_ICON_GENERATION} "for 24x24 icons.
This feature requires Python 3 and the lxml Python 3 module."
) # The exact amount of indentation used in the line(s) above is intentional
# When cross-compiling, we should compile qrcAlias natively (against a native Qt build)
if (CMAKE_CROSSCOMPILING)
set(BINARY_ICONS_RESOURCE_OPTION_DEFAULT OFF)
else()
set(BINARY_ICONS_RESOURCE_OPTION_DEFAULT ON)
endif()
option(BINARY_ICONS_RESOURCE "Install Qt binary resource files containing breeze icons (breeze-icons.rcc, breeze-icons-dark.rcc)" ${BINARY_ICONS_RESOURCE_OPTION_DEFAULT})
option(SKIP_INSTALL_ICONS "Skip installing the icons files" OFF)
if(BINARY_ICONS_RESOURCE)
find_package(Qt${QT_MAJOR_VERSION} NO_MODULE REQUIRED Core)
add_executable(qrcAlias qrcAlias.cpp)
target_link_libraries(qrcAlias PUBLIC Qt${QT_MAJOR_VERSION}::Core)
function(generate_binary_resource target outfile)
set(RESOURCES_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR}/res)
set(RESOURCE_FILE ${RESOURCES_WORKING_DIR}/breeze-${target}.qrc)
set(BINARY_RESOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/breeze-${target}.rcc)
# Use $<IF:$<BOOL:${MSVC}>,PATH,LD_LIBRARY_PATH> instead of ${pathVarName} once CMake 3.8 is minimum
if(MSVC)
set(pathVarName PATH)
else()
set(pathVarName LD_LIBRARY_PATH)
endif()
get_target_property(QT_RCC_EXECUTABLE Qt${QT_MAJOR_VERSION}::rcc LOCATION)
add_custom_target(breeze-${target}-mkdir
COMMAND ${CMAKE_COMMAND} -E make_directory ${RESOURCES_WORKING_DIR}
)
add_custom_command(OUTPUT ${RESOURCE_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${RESOURCES_WORKING_DIR}
COMMAND ${CMAKE_COMMAND} -E remove
${RESOURCE_FILE}
${RESOURCE_FILE}.depends
${RESOURCES_WORKING_DIR}/.gitignore
${RESOURCES_WORKING_DIR}/CMakeLists.txt
COMMAND ${QT_RCC_EXECUTABLE} --project -o ${CMAKE_CURRENT_BINARY_DIR}/tmp.qrc
COMMAND ${CMAKE_COMMAND} -E env
${pathVarName}=$<TARGET_FILE_DIR:Qt${QT_MAJOR_VERSION}::Core>
$<TARGET_FILE:qrcAlias> -i ${CMAKE_CURRENT_BINARY_DIR}/tmp.qrc -o ${RESOURCE_FILE}
WORKING_DIRECTORY ${RESOURCES_WORKING_DIR}
DEPENDS breeze-${target}-mkdir
)
add_custom_command(OUTPUT ${BINARY_RESOURCE_FILE}
COMMAND ${QT_RCC_EXECUTABLE} --binary
-o ${BINARY_RESOURCE_FILE}
${RESOURCE_FILE}
DEPENDS ${RESOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(breeze-${target}-rcc ALL DEPENDS ${BINARY_RESOURCE_FILE})
set(${outfile} ${BINARY_RESOURCE_FILE} PARENT_SCOPE)
endfunction()
endif()
if(NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
# validate
find_program(SH_EXE sh)
find_program(XMLLINT_EXE xmllint)
if(SH_EXE AND XMLLINT_EXE)
file(GLOB_RECURSE SVGS "icons/*.svg")
file(GLOB_RECURSE DARK_SVGS "icons-dark/*.svg")
# TODO: also make sure this is always run on generated icons
# not just by accident if the build directory is a subdir of the root source dir
add_custom_target(breeze-validate-svg ALL
COMMENT "Validating SVG"
COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/validate_svg.sh ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${SVGS} ${DARK_SVGS}
)
endif()
endif()
add_subdirectory(autotests)
add_subdirectory(icons)
add_subdirectory(icons-dark)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)