From 9c87aeb1fc2c4e2837d9b8c51347be5532ab42e2 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 18 Aug 2012 13:40:57 +0200 Subject: [PATCH] Add cmake Linux distro detection. --- CMakeLists.txt | 3 +++ CMakeModules/DetectDistro.cmake | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 CMakeModules/DetectDistro.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d1180065c..54409e9fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,9 @@ if(InSourceBuild) message(WARNING " mkdir ../fgbuild && cd ../fgbuild && cmake ${CMAKE_SOURCE_DIR}") endif(InSourceBuild) +# System detection/default settings +include( DetectDistro ) + set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows") set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows") set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows") diff --git a/CMakeModules/DetectDistro.cmake b/CMakeModules/DetectDistro.cmake new file mode 100644 index 000000000..99e82a0e3 --- /dev/null +++ b/CMakeModules/DetectDistro.cmake @@ -0,0 +1,13 @@ +# DetectDistro.cmake -- Detect Linux distribution + +message(STATUS "System is: ${CMAKE_SYSTEM_NAME}") + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + # Detect Linux distribution (if possible) + execute_process(COMMAND "/usr/bin/lsb-release" "-is" + TIMEOUT 4 + OUTPUT_VARIABLE LINUX_DISTRO + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Linux distro is: ${LINUX_DISTRO}") +endif()