Skip to content

Commit

Permalink
CMakeLists.txt: /etc/os-release to detect distro, fix for monero-proj…
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuodan committed Jun 15, 2018
1 parent 0339438 commit 99758ba
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ option(WITH_CPPNETLIB "Build with cpp-netlib" ON)
option(WITH_DOXYGEN "Enable support for Doxygen" OFF)
option(WITH_HARDENING "Use hardening compiler flags" OFF)
option(WITH_OPTIMIZE "Optimization flags" OFF)
option(WITH_PYTHON "Build wrappers which require Boost.Python" OFF)
option(WITH_PYTHON "Build wrappers which require Boost.Python" ON)
option(WITH_STATIC "Static build" OFF)
option(WITH_STATIC_DEPS "Static build with static dependencies" OFF)
option(WITH_SUPERCOP "Build Ed25519 using the ref10 implementation from SUPERCOP" ON) # Default ON unless we switch implementations
Expand Down Expand Up @@ -217,24 +217,25 @@ if(WITH_COTIRE)
include(cotire OPTIONAL)
endif()

# Get uname output
function(Uname output pattern)
# Get OS release name from /etc/os-release
function(DistroName output)
# regex for ^NAME=<DistroName>, exclude any quotes
set(distroname_regex "s/^['\"]?NAME['\"]?=['\"]?([^'\"]+)['\"]?$/\\1/p")
execute_process(
COMMAND sh -c "uname -a 2>&1"
COMMAND grep "${pattern}"
OUTPUT_VARIABLE ${output}
OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMAND sh -c "cat /etc/os-release 2>&1"
COMMAND sed -rn "${distroname_regex}"
OUTPUT_VARIABLE ${output}
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${output} "${${output}}" PARENT_SCOPE)
endfunction(Uname)
endfunction(DistroName)

# TODO(unassigned): extend Boost.Python cross-platform build support
set(additional_components)
if (WITH_PYTHON)
Uname(ARCH_LINUX "ARCH")
Uname(UBUNTU "Ubuntu")
if (APPLE OR ARCH_LINUX)
DistroName(DISTRO_NAME)
if (APPLE OR DISTRO_NAME STREQUAL "Arch Linux")
set(additional_components python3)
elseif (UBUNTU)
elseif (DISTRO_NAME STREQUAL "Ubuntu")
set(additional_components python-py35)
else()
message(FATAL_ERROR
Expand Down

0 comments on commit 99758ba

Please sign in to comment.