Skip to content

Commit

Permalink
ref #1093 macos uses homebrew environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Feb 28, 2024
1 parent 88571cd commit 7687c4d
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 84 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ jobs:
brew install libomp
brew link libomp --force
brew install openblas
brew install qt
brew link icu4c --force
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: "6.6.1"
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -55,11 +53,11 @@ jobs:

- name: Update version
run: |
python $GITHUB_WORKSPACE/tools/update_version/update_version.py
python3 $GITHUB_WORKSPACE/tools/update_version/update_version.py
- name: CMake
run: |
export HDF5_DIR=/opt/homebrew/opt/hdf5
export HDF5_DIR=$HOMEBREW_PREFIX/opt/hdf5
cmake -DCMAKE_BUILD_TYPE=Release -DWITHOUT_SLICOT_MODULE=ON -G "Unix Makefiles" .
- name: make
run: cmake --build . -- -j$(nproc)
Expand Down Expand Up @@ -88,7 +86,7 @@ jobs:
run: mkdir artifacts && mv tests_all*.* artifacts && mv benchs_all*.* artifacts && mv Nelson-*.tar.gz artifacts
- uses: actions/upload-artifact@v1
with:
name: nelson-github-action-artifacts-macOS-ventura-amd64-${{ steps.json_version.outputs.packageVersion }}.${{ github.run_number }}
name: nelson-github-action-artifacts-macOS-sonoma-arm64-${{ steps.json_version.outputs.packageVersion }}.${{ github.run_number }}
path: artifacts/

Ventura:
Expand Down Expand Up @@ -129,6 +127,7 @@ jobs:
brew install libomp
brew link libomp --force
brew install openblas
brew link icu4c --force
- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand Down Expand Up @@ -216,6 +215,7 @@ jobs:
brew install libomp
brew link libomp --force
brew install openblas
brew link icu4c --force
- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand Down
4 changes: 2 additions & 2 deletions CMake/FfiConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
"Brew reported an error:\n${BREW_ERROR}.\nPlease resolve this error.")
endif()
if(NOT LIBFFI_INCLUDE_DIR)
if(EXISTS "/opt/homebrew/opt/libffi/include/ffi.h")
set(LIBFFI_INCLUDE_DIR /opt/homebrew/opt/libffi/include)
if(EXISTS "$ENV{HOMEBREW_PREFIX}/opt/libffi/include/ffi.h")
set(LIBFFI_INCLUDE_DIR $ENV{HOMEBREW_PREFIX}/opt/libffi/include)
endif()
endif()
if(NOT LIBFFI_INCLUDE_DIR)
Expand Down
4 changes: 2 additions & 2 deletions CMake/FindLibFFI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ IF (NOT LIBFFI_INCLUDE_DIR)
ENDIF()
ENDIF()
IF (NOT LIBFFI_INCLUDE_DIR)
IF(EXISTS "/opt/homebrew/opt/libffi/include/ffi.h")
set(LIBFFI_INCLUDE_DIR "/opt/homebrew/opt/libffi/include")
IF(EXISTS "$ENV{HOMEBREW_PREFIX}/opt/libffi/include/ffi.h")
set(LIBFFI_INCLUDE_DIR "$ENV{HOMEBREW_PREFIX}/opt/libffi/include")
ENDIF()
ENDIF()
IF (NOT LIBFFI_INCLUDE_DIR)
Expand Down
4 changes: 2 additions & 2 deletions CMake/FindOpenBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else()
/usr/local/include/openblas-base
/usr/local/opt/openblas/include
/opt/OpenBLAS/include
/opt/homebrew/opt/openblas/include
$ENV{HOMEBREW_PREFIX}/opt/openblas/include
)

SET(Open_BLAS_LIB_SEARCH_PATHS
Expand All @@ -47,7 +47,7 @@ else()
/usr/local/lib64
/usr/local/opt/openblas/lib
/opt/OpenBLAS/lib
/opt/homebrew/opt/openblas/lib
$ENV{HOMEBREW_PREFIX}/opt/openblas/lib
)

endif()
Expand Down
84 changes: 30 additions & 54 deletions CMake/IcuConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,38 @@
# LICENCE_BLOCK_END
# ==============================================================================
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
execute_process(
COMMAND brew --prefix icu4c
OUTPUT_VARIABLE BREW_ICU_PREFIX
RESULT_VARIABLE NONZERO_BREW_EXIT_CODE
ERROR_VARIABLE BREW_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
if(NOT (NONZERO_BREW_EXIT_CODE))
set(CMAKE_ICU_PATH ${BREW_ICU_PREFIX})
else()
message(
FATAL_ERROR
"Brew reported an error:\n${BREW_ERROR}.\nPlease resolve this error.")
endif()

if(NOT ICU_INCLUDE_DIRS)
if(EXISTS "/usr/local/Cellar/icu4c/67.1/include")
set(ICU_INCLUDE_DIRS "/usr/local/Cellar/icu4c/67.1/include")
endif()
endif()
if(NOT ICU_INCLUDE_DIRS)
if(EXISTS "/usr/local/Cellar/icu4c/64.2/include")
set(ICU_INCLUDE_DIRS "/usr/local/Cellar/icu4c/64.2/include")
# Try finding ICU with Homebrew
execute_process(
COMMAND brew --prefix icu4c
OUTPUT_VARIABLE BREW_ICU_PREFIX
RESULT_VARIABLE NONZERO_BREW_EXIT_CODE
ERROR_VARIABLE BREW_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)

if(NOT NONZERO_BREW_EXIT_CODE)
set(CMAKE_ICU_PATH ${BREW_ICU_PREFIX})
endif()
endif()
if(NOT ICU_INCLUDE_DIRS)
if(EXISTS "${CMAKE_ICU_PATH}/include")

# If not found via Homebrew, try default paths
if(NOT CMAKE_ICU_PATH)
set(POSSIBLE_ICU_PATHS
"$ENV{HOMEBREW_PREFIX}/opt/icu4c"
"$ENV{HOMEBREW_CELLAR}/icu4c/67.1"
"$ENV{HOMEBREW_CELLAR}/icu4c/64.2"
)

foreach(PATH ${POSSIBLE_ICU_PATHS})
if(EXISTS "${PATH}/include" AND EXISTS "${PATH}/lib/libicuuc.dylib")
set(CMAKE_ICU_PATH ${PATH})
break()
endif()
endforeach()
endif()
# Set ICU_INCLUDE_DIRS and ICU_LIBRARIES if found
if(CMAKE_ICU_PATH)
set(ICU_INCLUDE_DIRS "${CMAKE_ICU_PATH}/include")
set(ICU_LIBRARIES "${CMAKE_ICU_PATH}/lib/libicuuc.dylib;${CMAKE_ICU_PATH}/lib/libicui18n.dylib")
endif()
endif()
if(NOT ICU_LIBRARIES)
if(EXISTS "/usr/local/Cellar/icu4c/67.1/lib/libicuuc.dylib")
set(ICU_LIBRARIES /usr/local/Cellar/icu4c/67.1/lib/libicuuc.dylib)
endif()
if(EXISTS "/usr/local/Cellar/icu4c/67.1/lib/libicui18n.dylib")
set(ICU_LIBRARIES
"${ICU_LIBRARIES};/usr/local/Cellar/icu4c/67.1/lib/libicui18n.dylib")
endif()
endif()
if(NOT ICU_LIBRARIES)
if(EXISTS "/usr/local/Cellar/icu4c/64.2/lib/libicuuc.dylib")
set(ICU_LIBRARIES /usr/local/Cellar/icu4c/64.2/lib/libicuuc.dylib)
endif()
if(EXISTS "/usr/local/Cellar/icu4c/64.2/lib/libicui18n.dylib")
set(ICU_LIBRARIES
"${ICU_LIBRARIES};/usr/local/Cellar/icu4c/64.2/lib/libicui18n.dylib")
endif()
endif()
if(NOT ICU_LIBRARIES)
if(EXISTS "${CMAKE_ICU_PATH}/lib/libicuuc.dylib")
set(ICU_LIBRARIES ${CMAKE_ICU_PATH}/lib/libicuuc.dylib)
endif()
if(EXISTS ${CMAKE_ICU_PATH}/lib/libicui18n.dylib)
set(ICU_LIBRARIES
"${ICU_LIBRARIES};${CMAKE_ICU_PATH}/lib/libicui18n.dylib")
endif()
endif()
endif()
# ==============================================================================
if(NOT ICU_INCLUDE_DIRS OR NOT ICU_LIBRARIES)
Expand All @@ -78,7 +54,7 @@ if(ICU_INCLUDE_DIRS AND ICU_LIBRARIES)
message(STATUS "ICU_LIBRARIES=${ICU_LIBRARIES}")
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(FATAL_ERROR "Please install: brew install icu4c.")
message(FATAL_ERROR "Please install: brew install icu4c and brew link icu4c --force ")
else()
message(FATAL_ERROR "Please install icu.")
endif()
Expand Down
4 changes: 2 additions & 2 deletions CMake/MacOsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(EXISTS "/usr/local/opt/openblas/lib/")
link_directories(/usr/local/opt/openblas/lib/)
endif()
if(EXISTS "/opt/homebrew/opt/openblas/lib/")
link_directories(/opt/homebrew/opt/openblas/lib/)
if(EXISTS "$ENV{HOMEBREW_PREFIX}/opt/openblas/lib/")
link_directories($ENV{HOMEBREW_PREFIX}/opt/openblas/lib/)
endif()
endif()
# ==============================================================================
3 changes: 2 additions & 1 deletion CMake/PackageConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Nelson-${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_CONTACT "nelson.numerical.computation@gmail.com")

if(UNIX)
set(CPACK_GENERATOR "TGZ")
if(APPLE)
# later
set(CPACK_GENERATOR "TGZ")
else(APPLE)
set(CPACK_GENERATOR "TGZ")
find_file(DEBIAN_FOUND debian_version debconf.conf PATHS /etc)
find_file(FEDORA_FOUND fedora-release PATHS /etc)
find_file(REDHAT_FOUND redhat-release inittab.RH PATHS /etc)
Expand Down
20 changes: 10 additions & 10 deletions CMake/PortAudioConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
if(PORTAUDIO_FOUND)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# workaround for github CI with catalina
if(EXISTS "/usr/local/Cellar/portaudio/19.7.0/include")
set(PORTAUDIO_INCLUDE_DIRS /usr/local/Cellar/portaudio/19.7.0/include)
elseif(EXISTS "/usr/local/Cellar/portaudio/19.6.0/include")
set(PORTAUDIO_INCLUDE_DIRS /usr/local/Cellar/portaudio/19.6.0/include)
if(EXISTS "$ENV{HOMEBREW_CELLAR}/portaudio/19.7.0/include")
set(PORTAUDIO_INCLUDE_DIRS $ENV{HOMEBREW_CELLAR}/portaudio/19.7.0/include)
elseif(EXISTS "$ENV{HOMEBREW_CELLAR}/portaudio/19.6.0/include")
set(PORTAUDIO_INCLUDE_DIRS $ENV{HOMEBREW_CELLAR}/portaudio/19.6.0/include)
endif()

if(EXISTS "/opt/homebrew/lib/libportaudio.dylib")
set(PORTAUDIO_LIBRARIES /opt/homebrew/lib/libportaudio.dylib)
elseif(EXISTS "/usr/local/Cellar/portaudio/19.7.0/lib/libportaudio.dylib")
if(EXISTS "$ENV{HOMEBREW_PREFIX}/lib/libportaudio.dylib")
set(PORTAUDIO_LIBRARIES $ENV{HOMEBREW_PREFIX}/lib/libportaudio.dylib)
elseif(EXISTS "$ENV{HOMEBREW_CELLAR}/portaudio/19.7.0/lib/libportaudio.dylib")
set(PORTAUDIO_LIBRARIES
/usr/local/Cellar/portaudio/19.7.0/lib/libportaudio.dylib)
elseif(EXISTS "/usr/local/Cellar/portaudio/19.6.0/lib/libportaudio.dylib")
$ENV{HOMEBREW_CELLAR}/portaudio/19.7.0/lib/libportaudio.dylib)
elseif(EXISTS "$ENV{HOMEBREW_CELLAR}/portaudio/19.6.0/lib/libportaudio.dylib")
set(PORTAUDIO_LIBRARIES
/usr/local/Cellar/portaudio/19.6.0/lib/libportaudio.dylib)
$ENV{HOMEBREW_CELLAR}/portaudio/19.6.0/lib/libportaudio.dylib)
endif()

message(STATUS "Found portaudio (MacOs): ${PORTAUDIO_LIBRARIES}")
Expand Down
6 changes: 3 additions & 3 deletions bin/macOS/nelson
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ if test -d "/usr/local/opt/qt5/bin"; then
export PATH=/usr/local/opt/qt5/bin:$PATH
fi
#==============================================================================
if test -d "/opt/homebrew/lib"; then
export LD_LIBRARY_PATH="/opt/homebrew/lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH"
if test -d "$HOMEBREW_PREFIX/lib"; then
export LD_LIBRARY_PATH="$HOMEBREW_PREFIX/lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$HOMEBREW_PREFIX/lib:$DYLD_LIBRARY_PATH"
fi
#==============================================================================
export LD_LIBRARY_PATH="$SCRIPT_DIRECTORY:$LD_LIBRARY_PATH"
Expand Down
3 changes: 2 additions & 1 deletion modules/help_tools/functions/qhelpgenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ function qhelpgenerator(varargin)
end
%=============================================================================
function qhelpgenerator_filename = get_help_generator_filename_by_hardcoded_path()
possible_qhelpgeneration_filenames = {'/opt/homebrew/share/qt/libexec/qhelpgenerator', ...

possible_qhelpgeneration_filenames = {[getenv('HOMEBREW_PREFIX'), '/share/qt/libexec/qhelpgenerator'], ...
'/usr/local/share/qt/libexec/qhelpgenerator', ...
'/usr/local/opt/qt6/bin/qhelpgenerator', ...
'/usr/local/opt/qt5/bin/qhelpgenerator', ...
Expand Down

0 comments on commit 7687c4d

Please sign in to comment.