File: CMakeLists.txt

package info (click to toggle)
qtcurve 1.9-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,000 kB
  • sloc: cpp: 70,231; perl: 123; sh: 122; xml: 46; makefile: 14
file content (258 lines) | stat: -rw-r--r-- 7,868 bytes parent folder | download | duplicates (2)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
## Setup
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

project(QtCurve)

include(FeatureSummary)

## Temporary
function(translate_add_sources)
endfunction()

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}"
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(CMakeCMacros)

## Version
set(QTCURVE_VERSION_MAJOR "1")
set(QTCURVE_VERSION_MINOR "9")
set(QTCURVE_VERSION_PATCH "0")
set(QTCURVE_VERSION "${QTCURVE_VERSION_MAJOR}.${QTCURVE_VERSION_MINOR}")
set(QTCURVE_VERSION_FULL "${QTCURVE_VERSION}.${QTCURVE_VERSION_PATCH}")

find_package(Git QUIET)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
  DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tools/gen-version.sh"
  WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_target(gen-git-ver ALL
  COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/gen-version.sh"
  "${CMAKE_CURRENT_BINARY_DIR}/version.cpp" "${QTCURVE_VERSION_FULL}"
  "${GIT_EXECUTABLE}"
  DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")

## Options
function(qtc_option name doc def_val)
  if(DEFINED "${name}")
    set("${name}_DEFINED" On PARENT_SCOPE)
  else()
    set("${name}_DEFINED" Off PARENT_SCOPE)
    set("${name}" "${def_val}" ${doc} PARENT_SCOPE)
  endif()
endfunction()
function(qtc_variable name doc def_val)
  if(DEFINED "${name}")
    set("${name}_DEFINED" On PARENT_SCOPE)
  else()
    set("${name}_DEFINED" Off PARENT_SCOPE)
    set("${name}" "${def_val}" PARENT_SCOPE)
  endif()
endfunction()
qtc_option(ENABLE_QT4 "Building Qt4 theme." On)
qtc_option(ENABLE_QT5 "Building Qt5 theme." On)
qtc_option(ENABLE_GTK2 "Building Gtk2 theme." On)
# option(ENABLE_GTK3 "Building Gtk3 theme." On)
option(ENABLE_TEST "Enable testing." On)
option(QTC_ENABLE_X11 "Enable X11" On)
option(QTC_INSTALL_PO "Install translation files." On)

if(ENABLE_QT4)
    qtc_option(QTC_QT4_ENABLE_KDE "Building Qt4 style with KDE4 support." On)
else()
    qtc_option(QTC_QT4_ENABLE_KDE "Building Qt4 style with KDE4 support." Off)
endif()
if(ENABLE_QT5)
    qtc_option(QTC_QT5_ENABLE_KDE
      "Building Qt5 style with KDE Frameworks 5 support." On)
else()
    qtc_option(QTC_QT5_ENABLE_KDE
      "Building Qt5 style with KDE Frameworks 5 support." Off)
endif()

option(QTC_QT4_STYLE_SUPPORT
  "Qt4 support for creating a style for each QtCurve theme." Off)

## Common settings.
# support an infix argument to have different qtcurve-utils libraries, e.g. for
# GTk2, Qt4 and Qt5
qtc_variable(QTC_UTILSLIB_INFIX "Infix for having multiple qtcurve-utils's" "")
qtc_variable(QTC_KDE4_DEFAULT_HOME
  "Path of kde4 home (relative to user home), for reading old theme files only"
  ".kde4")

if((QTC_KDE4_DEFAULT_HOME STREQUAL ".kde4") OR
    (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde") OR
    (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde4/") OR
    (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde/") OR
    (QTC_KDE4_DEFAULT_HOME STREQUAL ""))
  set(QTC_KDE4_DEFAULT_HOME_DEFAULT True)
else()
  set(QTC_KDE4_DEFAULT_HOME_DEFAULT False)
endif()

# set compiler flags earlier to prevent potential failure running find_package(KDE4)
# glibc 2.20 warns about _BSD_SOURCE if _DEFAULT_SOURCE is not defined.
cmake_c_add_flags(CMAKE_C_FLAGS -Wall -Wextra -Wno-cast-align
  -std=gnu99 -D_DEFAULT_SOURCE)
# Register storage class is deprecated in C++11 but is still used in Qt.
# Use compiler option (-Wno-deprecated-register) to suppress
# the warning in clang++.
# We use `override` in certain Qt Classes but the QObject macro does not use it
# Use compiler option (-Wno-inconsistent-missing-override) to suppress
# the warning in clang++ 3.6+.
cmake_c_add_flags(CMAKE_CXX_FLAGS -Wall -Wextra
  -Wno-deprecated-register -Wno-cast-align
  -Wno-inconsistent-missing-override)
if(NOT APPLE)
  # -std=c++0x is deprecated but gcc < 4.7 do not recognise c++11 ....
  cmake_c_add_flags(CMAKE_CXX_FLAGS -std=c++0x -D_DEFAULT_SOURCE)
  cmake_c_add_flags(CMAKE_SHARED_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
  cmake_c_add_flags(CMAKE_MODULE_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
else()
  cmake_c_add_flags(CMAKE_CXX_FLAGS -std=c++11)
endif()

if(QTC_QT4_ENABLE_KDE)
    find_package(KDE4 QUIET)
    set(KDE4_KDECONFIG_EXECUTABLE)
    find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config
      PATHS "${CMAKE_INSTALL_PREFIX}/bin" ${_KDEDIRS} /opt/kde4/bin
      NO_DEFAULT_PATH)
    if(NOT KDE4_KDECONFIG_EXECUTABLE)
      find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config)
    endif()
endif()

function(get_cmd_var varname def cmd)
  if(DEFINED ${varname})
    return()
  endif()
  if(cmd)
    execute_process(COMMAND "${cmd}" ${ARGN} OUTPUT_VARIABLE _cmd_out
      RESULT_VARIABLE _cmd_res)
    if("${_cmd_res}" EQUAL 0)
      string(STRIP "${_cmd_out}" _cmd_out)
    else()
      set(_cmd_out "${def}")
    endif()
  else()
    set(_cmd_out "${def}")
  endif()
  set("${varname}" "${_cmd_out}" PARENT_SCOPE)
endfunction()

function(get_kde_var var def)
  get_cmd_var(_output "${def}" "${KDE4_KDECONFIG_EXECUTABLE}" ${ARGN})
  set(${var} "${_output}" PARENT_SCOPE)
endfunction()

get_kde_var(QTC_KDE4_PREFIX "${CMAKE_INSTALL_PREFIX}" --prefix)
get_kde_var(QTC_KDE4_ICONS_PREFIX "${QTC_KDE4_PREFIX}/share/icons"
  --install icon)

## Handle options
find_package(Libexecinfo)
if(LIBEXECINFO_LIB_FOUND)
  set(QTC_ENABLE_BACKTRACE On)
else()
  set(QTC_ENABLE_BACKTRACE Off)
endif()

if(QTC_ENABLE_X11)
  macro(qtc_check_x11)
    find_package(PkgConfig)
    if(NOT PKG_CONFIG_FOUND)
      message(WARNING "Cannot find pkg-config, disable x11 support.")
      set(QTC_ENABLE_X11 Off)
      set(QTC_X11_FOUND Off)
      return()
    endif()
    unset(__pkg_config_checked_QTC_X11 CACHE)
    # pkg_check_modules(QTC_X11 xcb x11-xcb xrender)
    if(QTC_ENABLE_X11)
      pkg_check_modules(QTC_X11 xcb x11-xcb)
    else()
      pkg_check_modules(QTC_X11 xcb)
    endif()
    if(NOT QTC_X11_FOUND AND QTC_ENABLE_X11)
      message(WARNING
        "Cannot find required modules for x11, disable x11 support.")
      set(QTC_ENABLE_X11 Off)
      return()
    endif()
  endmacro()
  qtc_check_x11()
else()
  set(QTC_X11_FOUND Off)
endif()

if(QTC_X11_FOUND)
  include_directories(${QTC_X11_INCLUDE_DIRS})
  add_definitions(${QTC_X11_CFLAGS})
else()
  include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/lib/xcb-defs")
endif()

if(ENABLE_GTK2 AND NOT ENABLE_GTK2_DEFINED)
  find_package(PkgConfig)
  if(NOT PKG_CONFIG_FOUND)
    message(WARNING "pkg-config not found, disable Gtk2 build.")
    set(ENABLE_GTK2 Off)
  else()
    unset(__pkg_config_checked_GTK2 CACHE)
    pkg_check_modules(GTK2 gtk+-2.0)
    if(NOT GTK2_FOUND)
      message(WARNING "gtk+-2.0 not found, disable Gtk2 build.")
      set(ENABLE_GTK2 Off)
    endif()
  endif()
endif()

if(ENABLE_GTK2)
  find_package(PkgConfig REQUIRED)
  unset(__pkg_config_checked_GTK2 CACHE)
  pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
  if(GTK2_THEME_PREFIX)
    set(GTK2_PREFIX "${GTK2_THEME_PREFIX}")
  elseif(NOT GTK2_PREFIX)
    set(GTK2_PREFIX "${CMAKE_INSTALL_PREFIX}")
  endif()
  if(NOT GTK2_LIBDIR)
    set(GTK2_LIBDIR "${GTK2_PREFIX}/lib")
  endif()
  _pkgconfig_invoke(gtk+-2.0 GTK2 BIN_VERSION "" --variable=gtk_binary_version)
  set(GTK2_THEME_DIR ${GTK2_PREFIX}/share/themes/QtCurve)
endif()

configure_file(config.h.in config.h @ONLY)

include_directories("${CMAKE_CURRENT_BINARY_DIR}")
cmake_c_fix_include_path(lib/utils qtcurve-utils)
cmake_c_fix_include_path(lib/cairo qtcurve-cairo)
add_definitions("-D_GNU_SOURCE -pthread")

if(NOT DEFINED LIB_INSTALL_DIR)
  set(LIB_INSTALL_DIR lib)
endif()

cmake_c_include_fix_path()
add_subdirectory(lib)
if(ENABLE_QT4)
    add_subdirectory(qt4)
endif()
if(ENABLE_QT5)
    add_subdirectory(qt5)
endif()
if(ENABLE_GTK2)
    add_subdirectory(gtk2)
endif()
add_subdirectory(tools)
if(ENABLE_TEST)
  enable_testing()
  add_subdirectory(test)
endif()

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

find_package(KF5I18n CONFIG REQUIRED)
ki18n_install(po)