Skip to content

Commit

Permalink
Simplify brew prefix detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed May 23, 2024
1 parent c66af60 commit dde9bdf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF)


IF(LMMS_BUILD_APPLE)
# Fix linking on 10.14+. See issue #4762 on github
LINK_DIRECTORIES("${APPLE_PREFIX}/lib")
SET(WANT_SOUNDIO OFF)
SET(WANT_ALSA OFF)
SET(WANT_OSS OFF)
Expand Down
30 changes: 22 additions & 8 deletions cmake/modules/DetectMachine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,32 @@ ELSE(LMMS_BUILD_WIN32)
ENDIF(LMMS_BUILD_WIN32)

IF(LMMS_BUILD_APPLE)
# Detect cross-compilation. "wrongbrew" is a custom wrapper for homebrew
IF((CMAKE_APPLE_SILICON_PROCESSOR STREQUAL "x86_64" AND NOT LMMS_HOST_X86_64) OR
(CMAKE_APPLE_SILICON_PROCESSOR STREQUAL "arm64" AND NOT LMMS_HOST_ARM64))
EXECUTE_PROCESS(COMMAND wrongbrew --prefix RESULT_VARIABLE DETECT_WRONGBREW OUTPUT_VARIABLE WRONGBREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()

# Detect Homebrew versus Macports environment
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_HOMEBREW OUTPUT_VARIABLE HOMEBREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${DETECT_HOMEBREW} EQUAL 0)
SET(HOMEBREW 1)
SET(APPLE_PREFIX "${HOMEBREW_PREFIX}")
ELSEIF(${DETECT_MACPORTS} EQUAL 0)
SET(MACPORTS 1)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)

IF(DETECT_WRONGBREW EQUAL 0)
SET(HOMEBREW 1)
SET(WRONGBREW 1)
SET(APPLE_PREFIX "${WRONGBREW_PREFIX}/lib")
ELSEIF(DETECT_HOMEBREW EQUAL 0)
SET(HOMEBREW 1)
SET(APPLE_PREFIX "${HOMEBREW_PREFIX}")
ELSEIF(DETECT_MACPORTS EQUAL 0)
SET(MACPORTS 1)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX "${MACPORTS_PREFIX}" DIRECTORY)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX "${MACPORTS_PREFIX}" DIRECTORY)
SET(APPLE_PREFIX "${MACPORTS_PREFIX}")
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${APPLE_PREFIX}/lib)
ENDIF()

IF(APPLE_PREFIX)
LINK_DIRECTORIES("${APPLE_PREFIX}/lib")
ENDIF()

# Detect OS Version
Expand Down

0 comments on commit dde9bdf

Please sign in to comment.