cmake: Use GNUInstallDirs (#1818)
* Use GNUInstallDirs instead of hardcoded paths This change should be a no-op in the normal case and at the same time make it easier to customise polybar builds on systems with special needs. * Avoid creating /usr/share/doc/polybar/polybar/* * Include GNUInstallDirs for the doc target itself * cmake: Don't try to set CMAKE_INSTALL_* variables Since we include GNUInstallDirs all these variables are already set * cmake: Print install directories in summary * fix(cmake): Make doc-only work like normal build This is kind of a dirty hack to force CMAKE_INSTALL_DOCDIR to use `polybar` as the project name when only polybar-doc is built. Maybe it is wiser at some point to be able to do a doc only build (and install) that can be done from the top level project. Then we would also not need to include GNUInstallDirs here
This commit is contained in:
parent
0740382851
commit
43556b5d92
@ -46,6 +46,7 @@ set(CMAKE_MODULE_PATH
|
||||
${PROJECT_SOURCE_DIR}/cmake/common
|
||||
${PROJECT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(utils)
|
||||
include(01-core)
|
||||
include(02-opts)
|
||||
@ -160,8 +161,7 @@ configure_file(
|
||||
ESCAPE_QUOTES @ONLY)
|
||||
|
||||
install(FILES config
|
||||
DESTINATION share/doc/polybar
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT config)
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -72,20 +72,6 @@ elseif(CXXLIB_GCC)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
|
||||
endif()
|
||||
|
||||
# Install paths
|
||||
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_INSTALL_SBINDIR)
|
||||
set(CMAKE_INSTALL_SBINDIR sbin)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR lib)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
|
||||
set(CMAKE_INSTALL_INCLUDEDIR include)
|
||||
endif()
|
||||
|
||||
# Custom build type ; SANITIZE
|
||||
SET(CMAKE_CXX_FLAGS_SANITIZE "-O0 -g -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
|
||||
CACHE STRING "Flags used by the C++ compiler during sanitize builds." FORCE)
|
||||
|
@ -8,6 +8,13 @@ message_colored(STATUS " Type: ${CMAKE_BUILD_TYPE}" "37;2")
|
||||
message_colored(STATUS " CXX: ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
|
||||
message_colored(STATUS " LD: ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
|
||||
|
||||
message(STATUS " Install Paths:")
|
||||
message_colored(STATUS " PREFIX: ${CMAKE_INSTALL_PREFIX}" "32")
|
||||
message_colored(STATUS " BINDIR: ${CMAKE_INSTALL_FULL_BINDIR}" "32")
|
||||
message_colored(STATUS " DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}" "32")
|
||||
message_colored(STATUS " DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}" "32")
|
||||
message_colored(STATUS " MANDIR: ${CMAKE_INSTALL_FULL_MANDIR}" "32")
|
||||
|
||||
message(STATUS " Targets:")
|
||||
colored_option(" polybar-msg" BUILD_IPC_MSG)
|
||||
colored_option(" testsuite" BUILD_TESTS)
|
||||
|
@ -2,5 +2,5 @@
|
||||
# Bash completion template
|
||||
#
|
||||
install(FILES polybar
|
||||
DESTINATION share/bash-completion/completions
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions
|
||||
COMPONENT tools)
|
||||
|
@ -2,5 +2,5 @@
|
||||
# Zsh completion template
|
||||
#
|
||||
install(FILES _polybar _polybar_msg
|
||||
DESTINATION share/zsh/site-functions
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions
|
||||
COMPONENT tools)
|
||||
|
@ -47,10 +47,23 @@ endforeach()
|
||||
# Dummy target that depends on all documentation targets
|
||||
add_custom_target(doc ALL DEPENDS ${doc_targets})
|
||||
|
||||
# This is needed for the case where only the doc target is built
|
||||
# CMAKE_INSTALL_DOCDIR uses PROJECT_NAME which is now polybar-doc, to be
|
||||
# consistent with a regular install we temporarily override it with "polybar"
|
||||
# before including GNUInstallDirs
|
||||
# Also since no language is set and GNUInstallDirs cannot set
|
||||
# CMAKE_INSTALL_LIBDIR, so we set it to a dummy value to suppress a warning
|
||||
if(${CMAKE_PROJECT_NAME} STREQUAL "polybar-doc")
|
||||
set(PROJECT_NAME "polybar")
|
||||
set(CMAKE_INSTALL_LIBDIR "")
|
||||
include(GNUInstallDirs)
|
||||
set(PROJECT_NAME "polybar-doc")
|
||||
endif()
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
|
||||
DESTINATION share/doc/polybar
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT doc)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
|
||||
COMPONENT doc)
|
||||
|
Loading…
Reference in New Issue
Block a user