Skip to content

Commit

Permalink
brew install path has changed in newer macos
Browse files Browse the repository at this point in the history
[skip_build]
  • Loading branch information
sumeetchhetri committed Jun 9, 2024
1 parent 97afad2 commit 571cec5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 44 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,38 @@ concurrency:
jobs:
macos:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[skip_build]')"
if: "!contains(github.event.head_commit.message, '[skip_build_mac]')"
strategy:
matrix:
os: [macOS-latest]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
#brew unlink bazel
brew install ossp-uuid libmemcached boost jsoncpp apr apr-util httpd ninja
brew install openssl ossp-uuid libmemcached boost jsoncpp apr apr-util httpd ninja unixodbc mongo-c-driver
ls -ltr /usr/local/opt/
ls -ltr /opt/homebrew/include
ls -ltr /opt/homebrew/lib
pushd /tmp
wget -q https://ftp.osuosl.org/pub/blfs/conglomeration/unixODBC/unixODBC-2.3.12.tar.gz
tar zxf unixODBC-2.3.12.tar.gz
cd unixODBC-2.3.12
./configure && make && sudo make install
cd /tmp
rm -rf unixODBC-2.3.12
VERSION=1.26.2
wget "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/$VERSION.tar.gz" --output-document="mongo-c-driver-$VERSION.tar.gz"
tar xf "mongo-c-driver-$VERSION.tar.gz"
rm -f "mongo-c-driver-$VERSION.tar.gz"
cd mongo-c-driver-$VERSION/ && mkdir _build && cmake -S . -B _build \
-D ENABLE_EXTRA_ALIGNMENT=OFF \
-D ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -D ENABLE_TESTS=OFF -D ENABLE_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D BUILD_VERSION="$VERSION" \
-D ENABLE_SSL=OFF \
-D ENABLE_SASL=OFF \
-D ENABLE_MONGOC=ON && cmake --build _build --config RelWithDebInfo --parallel && sudo cmake --install _build
rm -rf "mongo-c-driver-$VERSION"
#wget -q https://ftp.osuosl.org/pub/blfs/conglomeration/unixODBC/unixODBC-2.3.12.tar.gz
#tar zxf unixODBC-2.3.12.tar.gz
#cd unixODBC-2.3.12
#./configure && make && sudo make install
#cd /tmp
#rm -rf unixODBC-2.3.12
#VERSION=1.26.2
#wget "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/$VERSION.tar.gz" --output-document="mongo-c-driver-$VERSION.tar.gz"
#tar xf "mongo-c-driver-$VERSION.tar.gz"
#rm -f "mongo-c-driver-$VERSION.tar.gz"
#cd mongo-c-driver-$VERSION/ && mkdir _build && cmake -S . -B _build \
#-D ENABLE_EXTRA_ALIGNMENT=OFF \
#-D ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -D ENABLE_TESTS=OFF -D ENABLE_EXAMPLES=OFF \
#-D CMAKE_BUILD_TYPE=RelWithDebInfo \
#-D BUILD_VERSION="$VERSION" \
#-D ENABLE_SSL=OFF \
#-D ENABLE_SASL=OFF \
#-D ENABLE_MONGOC=ON && cmake --build _build --config RelWithDebInfo --parallel && sudo cmake --install _build
#rm -rf "mongo-c-driver-$VERSION"
#if [ -f /usr/local/lib/libssl.dylib ]; then
# sudo mv /usr/local/lib/libssl.dylib /usr/local/lib/libssl_bak.dylib
#fi
Expand Down
71 changes: 49 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,31 @@ endif()
if(NOT CINATRA_INCLUDES)
set(CINATRA_INCLUDES "/cinatra/include")
endif()
if(NOT SSL_INC_DIR)
set(SSL_INC_DIR "/usr/local/opt/openssl/include")
endif()
if(NOT SSL_LIB)
set(SSL_LIB "/usr/local/opt/openssl/lib/libssl.dylib")
endif()
if(NOT CRYPTO_LIB)
set(CRYPTO_LIB "/usr/local/opt/openssl/lib/libcrypto.dylib")
endif()
#if(NOT SSL_INC_DIR)
# set(SSL_INC_DIR "/usr/local/opt/openssl/include")
#endif()
#if(NOT SSL_LIB)
# set(SSL_LIB "/usr/local/opt/openssl/lib/libssl.dylib")
#endif()
#if(NOT CRYPTO_LIB)
# set(CRYPTO_LIB "/usr/local/opt/openssl/lib/libcrypto.dylib")
#endif()

set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
set(CMAKE_VERBOSE_MAKEFILE off)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_INC_PATH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_INC_PATH}/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_INC_PATH}/include")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include")
if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/homebrew/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/include")
endif()
endif()
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})

Expand Down Expand Up @@ -158,9 +164,9 @@ set(HAVE_WINREGEX "")

if(APPLE)
set(OS_DARWIN 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${SSL_INC_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${SSL_INC_DIR}" "/usr/local/include")
include_directories("${SSL_INC_DIR}" "/usr/local/include")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${SSL_INC_DIR}")
set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/opt/homebrew/include")
include_directories("/usr/local/include" "/opt/homebrew/include")
elseif(MINGW)
set(OS_MINGW 1)
set(USE_WIN_IOCP 1)
Expand Down Expand Up @@ -222,7 +228,11 @@ endif()
if(CMAKE_INC_PATH)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_INC_PATH}/lib")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib -L/opt/homebrew/lib")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
endif()

set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
Expand Down Expand Up @@ -344,10 +354,10 @@ endif()
#if(NOT HAVE_SSLINC)
# message(FATAL_ERROR "openssl includes not found")
#endif()
if (APPLE)
set(HAVE_SSLLIB ${SSL_LIB})
set(HAVE_CRYPTOLIB ${CRYPTO_LIB})
else()
#if (APPLE)
# set(HAVE_SSLLIB ${SSL_LIB})
# set(HAVE_CRYPTOLIB ${CRYPTO_LIB})
#else()
if(NOT BUILD_SHARED_LIBS)
FIND_LIBRARY(HAVE_SSLLIB NAMES libssl.a ssl)
else()
Expand All @@ -372,7 +382,7 @@ else()
# if(NOT HAVE_CRYPTOLIB)
# message(FATAL_ERROR "crypto library not found")
# endif()
endif()
#endif()

#FIND_LIBRARY(HAVE_TBBLIB tbb)
#if(NOT HAVE_TBBLIB)
Expand Down Expand Up @@ -532,6 +542,11 @@ if(MOD_SDORM_SQL)
if(MINGW)
set(CMAKE_REQUIRED_INCLUDES "/usr/include/unixodbc")
include_directories("/usr/include/unixodbc")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/include/postgresql -I/opt/homebrew/include/pgsql")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/homebrew/include/postgresql -I/opt/homebrew/include/pgsql")
set(CMAKE_REQUIRED_INCLUDES "/opt/homebrew/include/postgresql" "/opt/homebrew/include/pgsql")
include_directories("/opt/homebrew/include/postgresql" "/opt/homebrew/include/pgsql")
endif()
endif()
CHECK_INCLUDE_FILE("sql.h" HAVE_SQLINC)
Expand Down Expand Up @@ -591,6 +606,12 @@ if(MOD_SDORM_MONGO)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0")
set(CMAKE_REQUIRED_INCLUDES "/usr/include/libmongoc-1.0" "/usr/include/libbson-1.0" "/usr/local/include/libmongoc-1.0" "/usr/local/include/libbson-1.0")
include_directories("/usr/include/libmongoc-1.0" "/usr/include/libbson-1.0" "/usr/local/include/libmongoc-1.0" "/usr/local/include/libbson-1.0")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/include/libmongoc-1.0 -I/opt/homebrew/include/libbson-1.0 ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/homebrew/include/libmongoc-1.0 -I/opt/homebrew/include/libbson-1.0")
set(CMAKE_REQUIRED_INCLUDES "/opt/homebrew/include/libmongoc-1.0" "/opt/homebrew/include/libbson-1.0")
include_directories("/opt/homebrew/include/libmongoc-1.0" "/opt/homebrew/include/libbson-1.0")
endif()
endif()
CHECK_INCLUDE_FILE("mongoc.h" HAVE_MONGOINC)
if(NOT HAVE_MONGOINC)
Expand Down Expand Up @@ -664,6 +685,9 @@ if(SRV_ALL)
set(CMAKE_JSONCPP_INC "${CMAKE_INC_PATH}/include/jsoncpp")
else()
set(CMAKE_JSONCPP_INC "/usr/local/include/jsoncpp" "/usr/include/jsoncpp")
if(APPLE)
set(CMAKE_JSONCPP_INC "/opt/homebrew/include/jsoncpp")
endif()
endif()
FIND_LIBRARY(HAVE_JSONCPP jsoncpp)
if(NOT HAVE_JSONCPP)
Expand Down Expand Up @@ -736,6 +760,9 @@ elseif(SRV_DROGON)
set(CMAKE_JSONCPP_INC "${CMAKE_INC_PATH}/include/jsoncpp")
else()
set(CMAKE_JSONCPP_INC "/usr/local/include/jsoncpp" "/usr/include/jsoncpp")
if(APPLE)
set(CMAKE_JSONCPP_INC "/opt/homebrew/include/jsoncpp")
endif()
endif()
FIND_LIBRARY(HAVE_JSONCPP jsoncpp)
if(NOT HAVE_JSONCPP)
Expand Down Expand Up @@ -927,10 +954,10 @@ if(SRV_CINATRA)
elseif (SRV_ALL)
MESSAGE( STATUS "CINATRA_INCLUDES: " ${CINATRA_INCLUDES} )
endif()
if (APPLE)
MESSAGE( STATUS "SSL_LIB: " ${SSL_LIB} )
MESSAGE( STATUS "CRYPTO_LIB: " ${CRYPTO_LIB} )
endif()
#if (APPLE)
# MESSAGE( STATUS "SSL_LIB: " ${SSL_LIB} )
# MESSAGE( STATUS "CRYPTO_LIB: " ${CRYPTO_LIB} )
#endif()

file(REMOVE_RECURSE ${PROJECT_NAME}-bin)
install(DIRECTORY DESTINATION "${PROJECT_NAME}-bin")
Expand Down

0 comments on commit 571cec5

Please sign in to comment.