From 615762d7b31b4ff0450136b063c7c0c5f33f6a05 Mon Sep 17 00:00:00 2001 From: aspen Date: Thu, 13 May 2021 11:41:29 -0400 Subject: [PATCH] Fix compilation on M1 macOS --- CMakeLists.txt | 23 ++++++++++++++++++++++- clean_build.sh | 2 +- dist/macos/bundle/build_dist.sh.in | 4 ++-- osx_environment.sh | 15 ++++++--------- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56b30be..1b7cb545 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,10 +317,21 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") ${OPENSSL_ROOT}/lib/ssleay32.lib ) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_program(APT_PROGRAM "apt") find_program(BREW_PROGRAM "brew") find_program(PORT_PROGRAM "port") - if (IS_DIRECTORY /opt/local AND PORT_PROGRAM) + if (IS_DIRECTORY /opt/procursus AND APT_PROGRAM) + # procursus/apt + set (OPENSSL_ROOT /opt/procursus) + + include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include) + + set (OPENSSL_LIBS + ${OPENSSL_ROOT}/lib/libssl.a + ${OPENSSL_ROOT}/lib/libcrypto.a + ) + elseif (IS_DIRECTORY /opt/local AND PORT_PROGRAM) # macports set (OPENSSL_ROOT /opt/local) @@ -335,6 +346,16 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include) + set (OPENSSL_LIBS + ${OPENSSL_ROOT}/lib/libssl.a + ${OPENSSL_ROOT}/lib/libcrypto.a + ) + elseif (IS_DIRECTORY /opt/homebrew/opt/openssl AND BREW_PROGRAM) + # brew + set (OPENSSL_ROOT /opt/homebrew/opt/openssl) + + include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include) + set (OPENSSL_LIBS ${OPENSSL_ROOT}/lib/libssl.a ${OPENSSL_ROOT}/lib/libcrypto.a diff --git a/clean_build.sh b/clean_build.sh index 3a92d8b9..f78bc463 100755 --- a/clean_build.sh +++ b/clean_build.sh @@ -14,7 +14,7 @@ if [ "$(uname)" = "Darwin" ]; then # OSX needs a lot of extra help, poor thing # run the osx_environment.sh script to fix paths . ./osx_environment.sh - B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 $B_CMAKE_FLAGS" + B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $B_CMAKE_FLAGS" fi # allow local customizations to build environment [ -r ./build_env.sh ] && . ./build_env.sh diff --git a/dist/macos/bundle/build_dist.sh.in b/dist/macos/bundle/build_dist.sh.in index c96da790..0db08286 100755 --- a/dist/macos/bundle/build_dist.sh.in +++ b/dist/macos/bundle/build_dist.sh.in @@ -48,7 +48,7 @@ fi # Check for macdeployqt on Homebrew if which -s brew ; then info "Homebrew found, searching for macdeployqt" - DEPLOYQT="$(brew list qt | grep --only '/.*macdeployqt' | head -1)" + DEPLOYQT="$(brew list qt5 | grep --only '/.*macdeployqt' | head -1)" if [ ! -x "$DEPLOYQT" ]; then error Please install package qt exit 1 @@ -70,4 +70,4 @@ else -executable="$B_BARRIERC" \ -executable="$B_BARRIERS" || exit 1 success "Bundle created successfully" -fi \ No newline at end of file +fi diff --git a/osx_environment.sh b/osx_environment.sh index 09fa3479..04f41c17 100644 --- a/osx_environment.sh +++ b/osx_environment.sh @@ -29,18 +29,15 @@ if [ ! $BARRIER_BUILD_ENV ]; then elif command -v brew; then printf "Detected Homebrew\n" - QT_PATH=$(brew --prefix qt) - OPENSSL_PATH=$(brew --prefix openssl) + QT_PATH=$(brew --prefix qt5) - check_dir_exists "$QT_PATH" 'qt' - check_dir_exists "$OPENSSL_PATH" 'openssl' + check_dir_exists "$QT_PATH" 'qt5' export BARRIER_BUILD_BREW=1 - export CMAKE_PREFIX_PATH="$QT_PATH:$CMAKE_PREFIX_PATH" - export LD_LIBRARY_PATH="$OPENSSL_PATH/lib:$LD_LIBRARY_PATH" - export CPATH="$OPENSSL_PATH/include:$CPATH" - export PKG_CONFIG_PATH="$OPENSSL_PATH/lib/pkgconfig:$PKG_CONFIG_PATH" - + export CMAKE_PREFIX_PATH="/opt/procursus:$QT_PATH:$CMAKE_PREFIX_PATH" + export LD_LIBRARY_PATH="/opt/procursus/lib:$LD_LIBRARY_PATH" + export CPATH="/opt/procursus/include:$CPATH" + export PKG_CONFIG_PATH="/opt/procursus/lib/pkgconfig:$PKG_CONFIG_PATH" else printf "Neither Homebrew nor Macports is installed. Can't get dependency paths\n" exit 1