|
| 1 | +project(compton) |
| 2 | +cmake_minimum_required(VERSION 2.8) |
| 3 | + |
| 4 | +set(CPACK_PACKAGE_VERSION_MAJOR "0") |
| 5 | +set(CPACK_PACKAGE_VERSION_MINOR "0") |
| 6 | +set(CPACK_PACKAGE_VERSION_PATCH "0") |
| 7 | + |
| 8 | +set(compton_SRCS src/compton.c) |
| 9 | +add_executable(compton ${compton_SRCS}) |
| 10 | + |
| 11 | +set(CMAKE_C_FLAGS_DEBUG "-ggdb") |
| 12 | +set(CMAKE_C_FLAGS_RELEASE "-O2 -march=native") |
| 13 | +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -march=native -ggdb") |
| 14 | + |
| 15 | +add_definitions("-Wall") |
| 16 | + |
| 17 | +# == Options == |
| 18 | + |
| 19 | +option(CONFIG_REGEX_PCRE "Enable PCRE regular expression support for blacklist entries (requires libpcre)" ON) |
| 20 | +if (CONFIG_REGEX_PCRE) |
| 21 | + add_definitions("-DCONFIG_REGEX_PCRE") |
| 22 | +endif () |
| 23 | + |
| 24 | +option(CONFIG_REGEX_PCRE_JIT "Use JIT support of libpcre)" ON) |
| 25 | +if (CONFIG_REGEX_PCRE_JIT) |
| 26 | + add_definitions("-DCONFIG_REGEX_PCRE_JIT") |
| 27 | +endif () |
| 28 | + |
| 29 | +option(CONFIG_LIBCONFIG "Enable configuration file parsing using libconfig" ON) |
| 30 | +if (CONFIG_LIBCONFIG) |
| 31 | + add_definitions("-DCONFIG_LIBCONFIG") |
| 32 | +endif () |
| 33 | + |
| 34 | +# == Find libraries == |
| 35 | + |
| 36 | +target_link_libraries(compton "-lm") |
| 37 | + |
| 38 | +include(FindPkgConfig) |
| 39 | + |
| 40 | +# --- Find X11 libs --- |
| 41 | +set(X11_FIND_REQUIRED 1) |
| 42 | +include(FindX11) |
| 43 | + |
| 44 | +macro(X11LIB_CHK lib) |
| 45 | + if (NOT X11_${lib}_FOUND) |
| 46 | + message(FATAL_ERROR "Could not find lib${lib}.") |
| 47 | + endif () |
| 48 | + target_link_libraries(compton "${X11_${lib}_LIB}") |
| 49 | +endmacro () |
| 50 | + |
| 51 | +X11LIB_CHK(Xcomposite) |
| 52 | +X11LIB_CHK(Xdamage) |
| 53 | +X11LIB_CHK(Xext) |
| 54 | +X11LIB_CHK(Xfixes) |
| 55 | +X11LIB_CHK(Xrender) |
| 56 | + |
| 57 | +# --- Find libpcre --- |
| 58 | +if (CONFIG_REGEX_PCRE) |
| 59 | + pkg_check_modules(LIBPCRE REQUIRED libpcre>=8.12) |
| 60 | + target_link_libraries(compton "${LIBPCRE_LDFLAGS}") |
| 61 | +endif () |
| 62 | + |
| 63 | +# --- Find libconfig --- |
| 64 | +if (CONFIG_LIBCONFIG) |
| 65 | + pkg_check_modules(LIBCONFIG REQUIRED libconfig>=1.3.2) |
| 66 | + target_link_libraries(compton "${LIBCONFIG_LDFLAGS}") |
| 67 | + if (LIBCONFIG_VERSION VERSION_LESS 1.4) |
| 68 | + add_definitions("-DCONFIG_LIBCONFIG_LEGACY") |
| 69 | + message(STATUS "libconfig-1.3* detected. Enable legacy mode.") |
| 70 | + endif () |
| 71 | +endif () |
| 72 | + |
| 73 | +# == Install == |
| 74 | +include(GNUInstallDirs) |
| 75 | + |
| 76 | +install(TARGETS compton |
| 77 | + DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog) |
| 78 | +install(FILES "${PROJECT_SOURCE_DIR}/bin/compton-trans" |
| 79 | + DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog) |
| 80 | +install(FILES |
| 81 | + "${PROJECT_SOURCE_DIR}/man/compton.1" |
| 82 | + "${PROJECT_SOURCE_DIR}/man/compton-trans.1" |
| 83 | + DESTINATION "${CMAKE_INSTALL_MANDIR}" COMPONENT doc) |
| 84 | +install(FILES |
| 85 | + "${PROJECT_SOURCE_DIR}/README.md" |
| 86 | + "${PROJECT_SOURCE_DIR}/LICENSE" |
| 87 | + DESTINATION "${CMAKE_INSTALL_DOCDIR}" COMPONENT doc) |
| 88 | + |
| 89 | +# == CPack == |
| 90 | + |
| 91 | +if (NOT CPACK_SYSTEM_NAME) |
| 92 | + set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_PROCESSOR}") |
| 93 | +endif () |
| 94 | + |
| 95 | +set(CPACK_PACKAGE_DESCRIPTION "A lightweight X compositing window manager, fork of xcompmgr-dana.") |
| 96 | +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A lightweight X compositing window manager") |
| 97 | +set(CPACK_PACKAGE_CONTACT "nobody <[email protected]>") |
| 98 | +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/release") |
| 99 | +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/desc.txt") |
| 100 | + |
| 101 | +# --- Package config --- |
| 102 | +set(CPACK_GENERATOR "TBZ2" "DEB" "RPM") |
| 103 | +set(CPACK_MONOLITHIC_INSTALL 1) |
| 104 | +set(CPACK_STRIP_FILES 1) |
| 105 | +set(CPACK_RESOURCE_FILE_LICENSE "LICENSE") |
| 106 | +set(CPACK_RESOURCE_FILE_README "README.md") |
| 107 | + |
| 108 | +# --- Source package config --- |
| 109 | +set(CPACK_SOURCE_GENERATOR "TBZ2" "DEB" "RPM") |
| 110 | +set(CPACK_SOURCE_IGNORE_FILES |
| 111 | + "/\\\\." |
| 112 | + "\\\\.bak$" |
| 113 | + "\\\\.o$" |
| 114 | + "\\\\~$" |
| 115 | + "\\\\.plist$" |
| 116 | + "/compton$" |
| 117 | + # Generated package files |
| 118 | + "\\\\.tar\\\\.gz$" |
| 119 | + "\\\\.tar\\\\.bz2$" |
| 120 | + "\\\\.deb$" |
| 121 | + "\\\\.rpm$" |
| 122 | + "compton-.*\\\\.sh$" |
| 123 | + # CMake files |
| 124 | + "/Makefile$" |
| 125 | + "/CMakeFiles/" |
| 126 | + "\\\\.cmake$" |
| 127 | + "CMakeCache\\\\.txt$" |
| 128 | + "/build/" |
| 129 | + "/release/" |
| 130 | + "\\\\.diff$" |
| 131 | + "/oprofile_data/" |
| 132 | + "/install_manifest\\\\.txt$" |
| 133 | +) |
| 134 | + |
| 135 | +# --- DEB package config --- |
| 136 | +set(CPACK_DEBIAN_PACKAGE_SECTION "x11") |
| 137 | +# The dependencies are unreliable, just an example here |
| 138 | +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libx11-6, libxext6, libxcomposite1, libxrender1, libxdamage1, libxfixes3, libpcre3, libconfig8") |
| 139 | + |
| 140 | +# --- RPM package config --- |
| 141 | +set(CPACK_RPM_PACKAGE_LICENSE "unknown") |
| 142 | +# The dependencies are unreliable, just an example here |
| 143 | +set(CPACK_RPM_PACKAGE_REQUIRES "libx11, libxext, libxcomposite, libxrender, libxdamage, libxfixes, libpcre, libconfig") |
| 144 | + |
| 145 | +include(CPack) |
0 commit comments