Warning, /system/qtcurve/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 ## Setup
0002 cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
0003 
0004 project(QtCurve)
0005 
0006 include(FeatureSummary)
0007 
0008 ## Temporary
0009 function(translate_add_sources)
0010 endfunction()
0011 
0012 set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}"
0013   "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
0014 
0015 include(CMakeCMacros)
0016 
0017 ## Version
0018 set(QTCURVE_VERSION_MAJOR "1")
0019 set(QTCURVE_VERSION_MINOR "9")
0020 set(QTCURVE_VERSION_PATCH "0-rc1")
0021 set(QTCURVE_VERSION "${QTCURVE_VERSION_MAJOR}.${QTCURVE_VERSION_MINOR}")
0022 set(QTCURVE_VERSION_FULL "${QTCURVE_VERSION}.${QTCURVE_VERSION_PATCH}")
0023 
0024 find_package(Git QUIET)
0025 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
0026   DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tools/gen-version.sh"
0027   WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
0028 add_custom_target(gen-git-ver ALL
0029   COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/gen-version.sh"
0030   "${CMAKE_CURRENT_BINARY_DIR}/version.cpp" "${QTCURVE_VERSION_FULL}"
0031   "${GIT_EXECUTABLE}"
0032   DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
0033 
0034 ## Options
0035 function(qtc_option name doc def_val)
0036   if(DEFINED "${name}")
0037     set("${name}_DEFINED" On PARENT_SCOPE)
0038   else()
0039     set("${name}_DEFINED" Off PARENT_SCOPE)
0040     set("${name}" "${def_val}" PARENT_SCOPE)
0041   endif()
0042 endfunction()
0043 qtc_option(ENABLE_QT4 "Building Qt4 theme." On)
0044 qtc_option(ENABLE_QT5 "Building Qt5 theme." On)
0045 qtc_option(ENABLE_GTK2 "Building Gtk2 theme." On)
0046 # option(ENABLE_GTK3 "Building Gtk3 theme." On)
0047 option(BUILD_TESTING "Enable testing." On)
0048 option(QTC_ENABLE_X11 "Enable X11" On)
0049 option(QTC_INSTALL_PO "Install translation files." On)
0050 
0051 if(ENABLE_QT4)
0052     qtc_option(QTC_QT4_ENABLE_KDE "Building Qt4 style with KDE4 support." On)
0053 else()
0054     qtc_option(QTC_QT4_ENABLE_KDE "Building Qt4 style with KDE4 support." Off)
0055 endif()
0056 if(ENABLE_QT5)
0057     qtc_option(QTC_QT5_ENABLE_KDE
0058       "Building Qt5 style with KDE Frameworks 5 support." On)
0059 else()
0060     qtc_option(QTC_QT5_ENABLE_KDE
0061       "Building Qt5 style with KDE Frameworks 5 support." Off)
0062 endif()
0063 
0064 option(QTC_QT4_STYLE_SUPPORT
0065   "Qt4 support for creating a style for each QtCurve theme." Off)
0066 
0067 ## Common settings.
0068 # support an infix argument to have different qtcurve-utils libraries, e.g. for
0069 # GTk2, Qt4 and Qt5
0070 qtc_option(QTC_UTILSLIB_INFIX "Infix for having multiple qtcurve-utils's" "")
0071 qtc_option(QTC_KDE4_DEFAULT_HOME
0072   "Path of kde4 home (relative to user home), for reading old theme files only"
0073   ".kde4")
0074 
0075 if((QTC_KDE4_DEFAULT_HOME STREQUAL ".kde4") OR
0076     (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde") OR
0077     (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde4/") OR
0078     (QTC_KDE4_DEFAULT_HOME STREQUAL ".kde/") OR
0079     (QTC_KDE4_DEFAULT_HOME STREQUAL ""))
0080   set(QTC_KDE4_DEFAULT_HOME_DEFAULT True)
0081 else()
0082   set(QTC_KDE4_DEFAULT_HOME_DEFAULT False)
0083 endif()
0084 
0085 # set compiler flags earlier to prevent potential failure running find_package(KDE4)
0086 # glibc 2.20 warns about _BSD_SOURCE if _DEFAULT_SOURCE is not defined.
0087 cmake_c_add_flags(CMAKE_C_FLAGS -Wall -Wextra -Wno-cast-align
0088   -std=gnu99 -D_DEFAULT_SOURCE)
0089 # Register storage class is deprecated in C++11 but is still used in Qt.
0090 # Use compiler option (-Wno-deprecated-register) to suppress
0091 # the warning in clang++.
0092 # We use `override` in certain Qt Classes but the QObject macro does not use it
0093 # Use compiler option (-Wno-inconsistent-missing-override) to suppress
0094 # the warning in clang++ 3.6+.
0095 cmake_c_add_flags(CMAKE_CXX_FLAGS -Wall -Wextra
0096   -Wno-deprecated-register -Wno-cast-align
0097   -Wno-inconsistent-missing-override)
0098 if(NOT APPLE)
0099   # -std=c++0x is deprecated but gcc < 4.7 do not recognise c++11 ....
0100   cmake_c_add_flags(CMAKE_CXX_FLAGS -std=c++0x -D_DEFAULT_SOURCE)
0101   cmake_c_add_flags(CMAKE_SHARED_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
0102   cmake_c_add_flags(CMAKE_MODULE_LINKER_FLAGS -Wl,--as-needed -Wl,--no-undefined)
0103 else()
0104   cmake_c_add_flags(CMAKE_CXX_FLAGS -std=c++11)
0105 endif()
0106 
0107 if(QTC_QT4_ENABLE_KDE)
0108     find_package(KDE4 QUIET)
0109     set(KDE4_KDECONFIG_EXECUTABLE)
0110     find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config
0111       PATHS "${CMAKE_INSTALL_PREFIX}/bin" ${_KDEDIRS} /opt/kde4/bin
0112       NO_DEFAULT_PATH)
0113     if(NOT KDE4_KDECONFIG_EXECUTABLE)
0114       find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config)
0115     endif()
0116 endif()
0117 
0118 function(get_cmd_var varname def cmd)
0119   if(DEFINED ${varname})
0120     return()
0121   endif()
0122   if(cmd)
0123     execute_process(COMMAND "${cmd}" ${ARGN} OUTPUT_VARIABLE _cmd_out
0124       RESULT_VARIABLE _cmd_res)
0125     if("${_cmd_res}" EQUAL 0)
0126       string(STRIP "${_cmd_out}" _cmd_out)
0127     else()
0128       set(_cmd_out "${def}")
0129     endif()
0130   else()
0131     set(_cmd_out "${def}")
0132   endif()
0133   set("${varname}" "${_cmd_out}" PARENT_SCOPE)
0134 endfunction()
0135 
0136 function(get_kde_var var def)
0137   get_cmd_var(_output "${def}" "${KDE4_KDECONFIG_EXECUTABLE}" ${ARGN})
0138   set(${var} "${_output}" PARENT_SCOPE)
0139 endfunction()
0140 
0141 get_kde_var(QTC_KDE4_PREFIX "${CMAKE_INSTALL_PREFIX}" --prefix)
0142 get_kde_var(QTC_KDE4_ICONS_PREFIX "${QTC_KDE4_PREFIX}/share/icons"
0143   --install icon)
0144 
0145 ## Handle options
0146 find_package(Libexecinfo)
0147 if(LIBEXECINFO_LIB_FOUND)
0148   set(QTC_ENABLE_BACKTRACE On)
0149 else()
0150   set(QTC_ENABLE_BACKTRACE Off)
0151 endif()
0152 
0153 if(QTC_ENABLE_X11)
0154   macro(qtc_check_x11)
0155     find_package(PkgConfig)
0156     if(NOT PKG_CONFIG_FOUND)
0157       message(WARNING "Cannot find pkg-config, disable x11 support.")
0158       set(QTC_ENABLE_X11 Off)
0159       set(QTC_X11_FOUND Off)
0160       return()
0161     endif()
0162     unset(__pkg_config_checked_QTC_X11 CACHE)
0163     # pkg_check_modules(QTC_X11 xcb x11-xcb xrender)
0164     if(QTC_ENABLE_X11)
0165       pkg_check_modules(QTC_X11 xcb x11-xcb)
0166     else()
0167       pkg_check_modules(QTC_X11 xcb)
0168     endif()
0169     if(NOT QTC_X11_FOUND AND QTC_ENABLE_X11)
0170       message(WARNING
0171         "Cannot find required modules for x11, disable x11 support.")
0172       set(QTC_ENABLE_X11 Off)
0173       return()
0174     endif()
0175   endmacro()
0176   qtc_check_x11()
0177 else()
0178   set(QTC_X11_FOUND Off)
0179 endif()
0180 
0181 if(QTC_X11_FOUND)
0182   include_directories(${QTC_X11_INCLUDE_DIRS})
0183   add_definitions(${QTC_X11_CFLAGS})
0184 else()
0185   include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/lib/xcb-defs")
0186 endif()
0187 
0188 if(ENABLE_GTK2 AND NOT ENABLE_GTK2_DEFINED)
0189   find_package(PkgConfig)
0190   if(NOT PKG_CONFIG_FOUND)
0191     message(WARNING "pkg-config not found, disable Gtk2 build.")
0192     set(ENABLE_GTK2 Off)
0193   else()
0194     unset(__pkg_config_checked_GTK2 CACHE)
0195     pkg_check_modules(GTK2 gtk+-2.0)
0196     if(NOT GTK2_FOUND)
0197       message(WARNING "gtk+-2.0 not found, disable Gtk2 build.")
0198       set(ENABLE_GTK2 Off)
0199     endif()
0200   endif()
0201 endif()
0202 
0203 if(ENABLE_GTK2)
0204   find_package(PkgConfig REQUIRED)
0205   unset(__pkg_config_checked_GTK2 CACHE)
0206   pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
0207   if(GTK2_THEME_PREFIX)
0208     set(GTK2_PREFIX "${GTK2_THEME_PREFIX}")
0209   elseif(NOT GTK2_PREFIX)
0210     set(GTK2_PREFIX "${CMAKE_INSTALL_PREFIX}")
0211   endif()
0212   if(NOT GTK2_LIBDIR)
0213     set(GTK2_LIBDIR "${GTK2_PREFIX}/lib")
0214   endif()
0215   _pkgconfig_invoke(gtk+-2.0 GTK2 BIN_VERSION "" --variable=gtk_binary_version)
0216   set(GTK2_THEME_DIR ${GTK2_PREFIX}/share/themes/QtCurve)
0217 endif()
0218 
0219 configure_file(config.h.in config.h @ONLY)
0220 
0221 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
0222 cmake_c_fix_include_path(lib/utils qtcurve-utils)
0223 cmake_c_fix_include_path(lib/cairo qtcurve-cairo)
0224 add_definitions("-D_GNU_SOURCE -pthread")
0225 
0226 if(NOT DEFINED LIB_INSTALL_DIR)
0227   set(LIB_INSTALL_DIR lib)
0228 endif()
0229 
0230 cmake_c_include_fix_path()
0231 add_subdirectory(lib)
0232 if(ENABLE_QT4)
0233     add_subdirectory(qt4)
0234 endif()
0235 if(ENABLE_QT5)
0236     add_subdirectory(qt5)
0237 endif()
0238 if(ENABLE_GTK2)
0239     add_subdirectory(gtk2)
0240 endif()
0241 add_subdirectory(tools)
0242 if(BUILD_TESTING)
0243   enable_testing()
0244   add_subdirectory(test)
0245 endif()
0246 
0247 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)