Skip to content

Commit 40926ea

Browse files
committed
Add detection of used Linux distribution.
This information is then used to put the bash completion files into the right directory.
1 parent 23fd0c8 commit 40926ea

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ math(EXPR LDC_LLVM_VER ${LLVM_VERSION_MAJOR}*100+${LLVM_VERSION_MINOR})
2020
#
2121
find_package(LibConfig++ REQUIRED)
2222

23+
#
24+
# Get info about used Linux distribution.
25+
#
26+
include(GetLinuxDistribution)
27+
2328
#
2429
# Main configuration.
2530
#
@@ -431,5 +436,9 @@ install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.conf DESTINATION ${CO
431436
install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.rebuild.conf DESTINATION ${CONF_INST_DIR} RENAME ${LDC_EXE}.rebuild.conf)
432437

433438
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
434-
install(DIRECTORY bash_completion.d DESTINATION ${CONF_INST_DIR})
439+
set(BASH_COMPLETION_INST_DIR "${CONF_INST_DIR}/bash_completion.d")
440+
if(LINUX_DISTRIBUTION_IS_GENTOO)
441+
set(BASH_COMPLETION_INST_DIR "/usr/share/bash-completion")
442+
endif()
443+
install(DIRECTORY bash_completion.d/ DESTINATION ${BASH_COMPLETION_INST_DIR})
435444
endif()
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Gets the linux distribution
2+
#
3+
# This module defines:
4+
# LINUX_DISTRIBUTION_IS_REDHAT
5+
# LINUX_DISTRIBUTION_IS_GENTOO
6+
7+
# Check: Can /usr/bin/lsb_release -a be used?
8+
9+
set(LINUX_DISTRIBUTION_IS_REDHAT FALSE)
10+
set(LINUX_DISTRIBUTION_IS_GENTOO FALSE)
11+
12+
if (UNIX)
13+
if (EXISTS "/etc/redhat-release")
14+
set(LINUX_DISTRIBUTION_IS_REDHAT TRUE)
15+
endif()
16+
17+
if (EXISTS "/etc/gentoo-release")
18+
set(LINUX_DISTRIBUTION_IS_GENTOO TRUE)
19+
endif()
20+
endif()

0 commit comments

Comments
 (0)