diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 98 |
1 files changed, 68 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bf55c5..f1d4292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,14 @@ -cmake_minimum_required (VERSION 3.0) -project (desktop-tools VERSION 0.1.0 LANGUAGES C) +cmake_minimum_required (VERSION 3.10) +project (desktop-tools VERSION 0.1.0 DESCRIPTION "Desktop tools" LANGUAGES C) # Moar warnings +set (CMAKE_C_STANDARD 99) +set (CMAKE_C_STANDARD_REQUIRED ON) +set (CMAKE_C_EXTENSIONS OFF) + if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC) # -Wunused-function is pretty annoying here, as everything is static - set (wdisabled "-Wno-unused-function") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra ${wdisabled}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function") endif () # Dependencies @@ -13,29 +16,50 @@ set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake) include (AddThreads) find_package (PkgConfig REQUIRED) -pkg_check_modules (dependencies REQUIRED libpulse x11 xext xextproto dbus-1) +pkg_check_modules (x REQUIRED x11 xext xextproto) +pkg_check_modules (pulse REQUIRED libpulse) +pkg_check_modules (dbus REQUIRED dbus-1) pkg_check_modules (gdm gdm glib-2.0 gio-2.0) -include_directories (${dependencies_INCLUDE_DIRS}) +include_directories ( + ${x_INCLUDE_DIRS} ${pulse_INCLUDE_DIRS} ${dbus_INCLUDE_DIRS}) +link_directories ( + ${x_LIBRARY_DIRS} ${pulse_LIBRARY_DIRS} ${dbus_LIBRARY_DIRS}) option (WITH_GDM "Compile with GDM support" ${gdm_FOUND}) # Generate a configuration file -configure_file (${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h) +configure_file (${PROJECT_SOURCE_DIR}/config.h.in + ${PROJECT_BINARY_DIR}/config.h) include_directories (${PROJECT_BINARY_DIR}) # Build -foreach (name brightness fancontrol-ng iexec input-switch priod siprandom) - add_executable (${name} ${name}.c) -endforeach () +set (targets wmstatus paswitch siprandom) +if ("${CMAKE_SYSTEM_NAME}" STREQUAL Linux) + # These use Linux i2c APIs, but can be made to work on macOS + list (APPEND targets brightness input-switch) + # Only iexec could be made to use kqueue + list (APPEND targets fancontrol-ng priod iexec) +elseif ("${CMAKE_SYSTEM_NAME}" MATCHES BSD) + # Need this for SIGWINCH in FreeBSD and OpenBSD respectively; + # our POSIX version macros make it undefined + add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1) +elseif (APPLE) + add_definitions (-D_DARWIN_C_SOURCE) +endif () -foreach (name big-brother paswitch wmstatus) +foreach (name big-brother ${targets}) add_executable (${name} ${name}.c) - target_link_libraries (${name} ${dependencies_LIBRARIES}) endforeach () + +target_link_libraries (big-brother ${x_LIBRARIES}) +target_link_libraries (paswitch ${pulse_LIBRARIES}) +target_link_libraries (wmstatus + ${x_LIBRARIES} ${pulse_LIBRARIES} ${dbus_LIBRARIES}) add_threads (wmstatus) if (WITH_GDM) include_directories (${gdm_INCLUDE_DIRS}) + link_directories (${gdm_LIBRARY_DIRS}) add_executable (gdm-switch-user gdm-switch-user.c) target_link_libraries (gdm-switch-user ${gdm_LIBRARIES}) endif () @@ -47,33 +71,47 @@ include (GNUInstallDirs) set (SYSTEMD_UNITDIR /lib/systemd/system CACHE PATH "Base directory for systemd unit files") -configure_file (${PROJECT_SOURCE_DIR}/fancontrol-ng.service.in - ${PROJECT_BINARY_DIR}/fancontrol-ng.service @ONLY) -install (FILES fancontrol-ng.conf.example - DESTINATION ${CMAKE_INSTALL_DATADIR}/fancontrol-ng) - -configure_file (${PROJECT_SOURCE_DIR}/priod.service.in - ${PROJECT_BINARY_DIR}/priod.service @ONLY) -install (FILES priod.conf.example - DESTINATION ${CMAKE_INSTALL_DATADIR}/priod) - -# System-wide unit files should be installed under /lib and not /usr/lib -install (FILES - ${PROJECT_BINARY_DIR}/fancontrol-ng.service - ${PROJECT_BINARY_DIR}/priod.service - DESTINATION "${SYSTEMD_UNITDIR}") +if ("${CMAKE_SYSTEM_NAME}" STREQUAL Linux) + configure_file (${PROJECT_SOURCE_DIR}/fancontrol-ng.service.in + ${PROJECT_BINARY_DIR}/fancontrol-ng.service @ONLY) + install (FILES fancontrol-ng.conf.example + DESTINATION ${CMAKE_INSTALL_DATADIR}/fancontrol-ng) + + configure_file (${PROJECT_SOURCE_DIR}/priod.service.in + ${PROJECT_BINARY_DIR}/priod.service @ONLY) + install (FILES priod.conf.example + DESTINATION ${CMAKE_INSTALL_DATADIR}/priod) + + # System-wide unit files should be installed under /lib and not /usr/lib + install (FILES + ${PROJECT_BINARY_DIR}/fancontrol-ng.service + ${PROJECT_BINARY_DIR}/priod.service + DESTINATION "${SYSTEMD_UNITDIR}") +endif () if (WITH_GDM) install (TARGETS gdm-switch-user DESTINATION ${CMAKE_INSTALL_BINDIR}) endif () -install (TARGETS wmstatus paswitch brightness input-switch fancontrol-ng priod - iexec siprandom DESTINATION ${CMAKE_INSTALL_BINDIR}) +# These should be accessible by users, but need to touch system devices. +# Use the setuid bit, for simplicity. +foreach (target brightness input-switch) + if (${target} IN_LIST targets) + list (REMOVE_ITEM targets ${target}) + install (TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS + OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + SETUID) + endif () +endforeach () + +install (TARGETS ${targets} DESTINATION ${CMAKE_INSTALL_BINDIR}) install (PROGRAMS shellify DESTINATION ${CMAKE_INSTALL_BINDIR}) install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) # CPack -set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Desktop tools") set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch") set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>") set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") |