Update CMake scripts to be compatible with different Homebrew install paths.

This commit is contained in:
casey langen 2021-06-13 20:24:19 -07:00
parent 70a35adf39
commit bd870de626
2 changed files with 31 additions and 14 deletions

View File

@ -1,10 +1,17 @@
function(ensure_library_exists libname)
get_property(ALL_LINK_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LINK_DIRECTORIES)
foreach(CURRENT_LINK_DIR ${ALL_LINK_DIRS})
unset(__TEMP_ENSURE_LIBRARY CACHE)
find_library(__TEMP_ENSURE_LIBRARY ${libname})
find_library(
__TEMP_ENSURE_LIBRARY
NAMES ${libname}
PATHS ${CURRENT_LINK_DIR})
if(NOT __TEMP_ENSURE_LIBRARY)
message(FATAL_ERROR "\n\n[check-dependencies] ${libname} not found\n\n")
#message(STATUS "[check-dependencies] ${libname} not found")
else()
message(STATUS "[check-dependencies] ${libname} found at ${__TEMP_ENSURE_LIBRARY}")
return()
endif()
unset(__TEMP_ENSURE_LIBRARY CACHE)
endforeach()
message(FATAL_ERROR "\n\n[check-dependencies] ${libname} not found\n\n")
endfunction(ensure_library_exists)

View File

@ -38,12 +38,22 @@ link_directories ("${musikcube_SOURCE_DIR}/bin/plugins")
# custom include/library directories for BSDs
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
link_directories ("/usr/local/lib")
link_directories ("/usr/local/opt/openssl/lib")
link_directories ("/usr/local/opt/ncurses/lib")
include_directories("/usr/local/include")
include_directories("/usr/local/opt/openssl/include")
include_directories("/usr/local/opt/ncurses/include")
set(BSD_PATH_PREFIX "/usr/local")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew config
COMMAND grep -i HOMEBREW_PREFIX
COMMAND awk "{print $2}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BSD_PATH_PREFIX)
endif()
message(STATUS "resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'")
link_directories ("${BSD_PATH_PREFIX}/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/openssl/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/ncurses/lib")
include_directories("${BSD_PATH_PREFIX}/include")
include_directories("${BSD_PATH_PREFIX}/opt/openssl/include")
include_directories("${BSD_PATH_PREFIX}/opt/ncurses/include")
endif ()
if (${LINK_STATICALLY} MATCHES "true")