From 40926eaba5bf38c8e5f289b9bf7c2a9b1e09bf43 Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 16 Jun 2013 22:17:57 +0200 Subject: [PATCH] Add detection of used Linux distribution. This information is then used to put the bash completion files into the right directory. --- CMakeLists.txt | 11 ++++++++++- cmake/Modules/GetLinuxDistribution.cmake | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/GetLinuxDistribution.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 46f13575..b7a13457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,11 @@ math(EXPR LDC_LLVM_VER ${LLVM_VERSION_MAJOR}*100+${LLVM_VERSION_MINOR}) # find_package(LibConfig++ REQUIRED) +# +# Get info about used Linux distribution. +# +include(GetLinuxDistribution) + # # Main configuration. # @@ -431,5 +436,9 @@ install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.conf DESTINATION ${CO install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.rebuild.conf DESTINATION ${CONF_INST_DIR} RENAME ${LDC_EXE}.rebuild.conf) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - install(DIRECTORY bash_completion.d DESTINATION ${CONF_INST_DIR}) + set(BASH_COMPLETION_INST_DIR "${CONF_INST_DIR}/bash_completion.d") + if(LINUX_DISTRIBUTION_IS_GENTOO) + set(BASH_COMPLETION_INST_DIR "/usr/share/bash-completion") + endif() + install(DIRECTORY bash_completion.d/ DESTINATION ${BASH_COMPLETION_INST_DIR}) endif() diff --git a/cmake/Modules/GetLinuxDistribution.cmake b/cmake/Modules/GetLinuxDistribution.cmake new file mode 100644 index 00000000..1d1b7f51 --- /dev/null +++ b/cmake/Modules/GetLinuxDistribution.cmake @@ -0,0 +1,20 @@ +# Gets the linux distribution +# +# This module defines: +# LINUX_DISTRIBUTION_IS_REDHAT +# LINUX_DISTRIBUTION_IS_GENTOO + +# Check: Can /usr/bin/lsb_release -a be used? + +set(LINUX_DISTRIBUTION_IS_REDHAT FALSE) +set(LINUX_DISTRIBUTION_IS_GENTOO FALSE) + +if (UNIX) + if (EXISTS "/etc/redhat-release") + set(LINUX_DISTRIBUTION_IS_REDHAT TRUE) + endif() + + if (EXISTS "/etc/gentoo-release") + set(LINUX_DISTRIBUTION_IS_GENTOO TRUE) + endif() +endif() \ No newline at end of file