From b0cfb4e93374a4b39c64e56739a74e2986f97293 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Sat, 14 Jan 2017 16:16:20 +0000 Subject: [PATCH] Allow docdir to be defined at build-time - Simplify by using GNUInstallDirs module - Move html documentation into an html subdirectory --- CMakeLists.txt | 32 ++++++++++++++++++-------------- src/tint2conf/CMakeLists.txt | 12 ++++-------- src/tint2conf/po/CMakeLists.txt | 2 +- themes/CMakeLists.txt | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bf8df2..5139e2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project( tint2 ) -cmake_minimum_required( VERSION 2.6 ) +cmake_minimum_required( VERSION 2.8.5 ) option( ENABLE_BATTERY "Enable battery status plugin" ON ) option( ENABLE_TINT2CONF "Enable tint2conf build, a GTK+2 theme configurator for tint2" ON ) @@ -13,6 +13,14 @@ if( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) option( ENABLE_UEVENT "Kernel event handling support" ON ) endif( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) +include( GNUInstallDirs ) +if(NOT docdir) + set(docdir ${CMAKE_INSTALL_DOCDIR}) +endif() +if(NOT htmldir) + set(htmldir ${docdir}/html) +endif() + include( FindPkgConfig ) include( CheckLibraryExists ) include( CheckCSourceCompiles ) @@ -200,11 +208,6 @@ else() SET(ASAN_L_FLAGS "") endif() -set( MANDIR share/man CACHE PATH "Directory for man pages" ) -set( DATADIR share CACHE PATH "Directory for shared data" ) -set( SYSCONFDIR /etc CACHE PATH "Directory for configuration files" ) -set( DOCDIR share/doc/tint2 CACHE PATH "Directory for documentation files" ) - add_custom_target( version ALL "${PROJECT_SOURCE_DIR}/get_version.sh" "\"${PROJECT_SOURCE_DIR}\"" ) link_directories( ${X11_LIBRARY_DIRS} @@ -243,14 +246,15 @@ set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fn set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS} ${BACKTRACE_L_FLAGS}" ) install( TARGETS tint2 DESTINATION bin ) -install( FILES tint2.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps ) -install( FILES tint2.desktop DESTINATION ${DATADIR}/applications ) -install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" ) -install( FILES themes/tint2rc DESTINATION ${SYSCONFDIR}/xdg/tint2 ) -install( FILES default_icon.png DESTINATION ${DATADIR}/tint2 ) -install( FILES AUTHORS ChangeLog README.md doc/tint2.md doc/manual.html doc/readme.html DESTINATION ${DOCDIR} ) -install( DIRECTORY doc/images DESTINATION ${DOCDIR} ) -install( FILES doc/tint2.1 DESTINATION ${MANDIR}/man1 ) +install( FILES tint2.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps ) +install( FILES tint2.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) +install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" ) +install( FILES themes/tint2rc DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/tint2 ) +install( FILES default_icon.png DESTINATION ${CMAKE_INSTALL_DATADIR}/tint2 ) +install( FILES AUTHORS ChangeLog README.md doc/tint2.md DESTINATION ${docdir} ) +install( FILES doc/manual.html doc/readme.html DESTINATION ${htmldir} ) +install( DIRECTORY doc/images DESTINATION ${htmldir} ) +install( FILES doc/tint2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 ) if( ENABLE_EXTRA_THEMES ) add_subdirectory(themes) endif( ENABLE_EXTRA_THEMES ) diff --git a/src/tint2conf/CMakeLists.txt b/src/tint2conf/CMakeLists.txt index 9595f6a..0e77857 100644 --- a/src/tint2conf/CMakeLists.txt +++ b/src/tint2conf/CMakeLists.txt @@ -57,12 +57,8 @@ target_link_libraries( tint2conf ${X11_T2C_LIBRARIES} ${GTK2_LIBRARIES} ${RSVG_LIBRARIES} ) -if ( NOT DATADIR ) - set(DATADIR share) -endif( NOT DATADIR ) - add_definitions( -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" ) -add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale\" ) +add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\" ) add_definitions( -DGETTEXT_PACKAGE=\"tint2conf\" ) set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -pthread -std=c99" ) set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" ) @@ -70,6 +66,6 @@ set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" ) add_subdirectory(po) install( TARGETS tint2conf DESTINATION bin ) -install( FILES tint2conf.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps ) -install( FILES tint2conf.desktop DESTINATION ${DATADIR}/applications ) -install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" ) +install( FILES tint2conf.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps ) +install( FILES tint2conf.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications ) +install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" ) diff --git a/src/tint2conf/po/CMakeLists.txt b/src/tint2conf/po/CMakeLists.txt index 1d9c8ba..29fb974 100644 --- a/src/tint2conf/po/CMakeLists.txt +++ b/src/tint2conf/po/CMakeLists.txt @@ -11,7 +11,7 @@ if (GETTEXT_FOUND) foreach(LANG ${LANGUAGES}) GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo" - DESTINATION "${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale/${LANG}/LC_MESSAGES" + DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES" RENAME "${GETTEXT_PACKAGE}.mo") endforeach () endif() diff --git a/themes/CMakeLists.txt b/themes/CMakeLists.txt index 5d78457..b30e693 100644 --- a/themes/CMakeLists.txt +++ b/themes/CMakeLists.txt @@ -1,2 +1,2 @@ file( GLOB EXTRATHEMEFILES *.tint2rc ) -install( FILES ${EXTRATHEMEFILES} DESTINATION ${DATADIR}/tint2 ) +install( FILES ${EXTRATHEMEFILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/tint2 )