Skip to content

Commit

Permalink
Fix Mac OS X builds when homebrew is not used.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Apr 21, 2019
1 parent 0b5c71f commit a893f27
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,28 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")

include (FindPkgConfig)

if( APPLE )
# Support homebrew installed openssl
find_library (LIBCRYPTO_LIBRARIES REQUIRED crypto PATHS /usr/local/opt/openssl/lib)
set (LIBCRYPTO_INCLUDE_DIRS /usr/local/opt/openssl/include)

find_package( OpenSSL REQUIRED )
find_package( Sqlite3 REQUIRED )
set(LIBCRYPTO_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
set(LIBCRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})

elseif( UNIX )

include (FindPkgConfig)
pkg_check_modules(LIBCRYPTO REQUIRED libcrypto)
pkg_check_modules(SQLITE REQUIRED sqlite3)

endif()

pkg_check_modules(SQLITE REQUIRED sqlite3)

include_directories( "${PROJECT_SOURCE_DIR}" ${JWT_CPP_INCLUDES} ${CURL_INCLUDES} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} )

add_library(SciTokens SHARED src/scitokens.cpp src/scitokens_internal.cpp src/scitokens_cache.cpp)
target_link_libraries(SciTokens ${LIBCRYPTO_LIBRARIES} ${CURL_LIBRARIES} ${SQLITE_LIBRARIES} ${UUID_LIBRARIES})

if ( UNIX )
if ( NOT APPLE AND UNIX )
set_target_properties(SciTokens PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR}/configs/export-symbols")
endif()

Expand Down
53 changes: 53 additions & 0 deletions cmake/FindSqlite3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# - Try to find SQLITE3
#
# SQLITE3_FOUND - system has SQLITE3
# SQLITE3_INCLUDE_DIRS - the SQLITE3 include directory
# SQLITE3_LIBRARIES - Link these to use SQLITE3
#

include(CheckSymbolExists)

FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite)

find_path(SQLITE3_INCLUDE_DIR
NAMES
sqlite3.h
PATHS
${SQLITE3_DIR}
$ENV{SQLITE3_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
)

find_library(SQLITE3_LIBRARY
NAMES
sqlite3
PATHS
${SQLITE_DIR}
$ENV{SQLITE_DIR}
~/Library/Frameworks
/Library/Frameworks
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)

IF(SQLITE3_FOUND)

SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
SET(SQLITE_LIBRARIES ${SQLITE3_LIBRARY})
SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
SET(SQLITE_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})

ELSE()

SET(SQLITE_LIBRARIES)
SET(SQLITE3_LIBRARIES)
SET(SQLITE_INCLUDE_DIRS)
SET(SQLITE3_INCLUDE_DIRS)

endif()

mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES SQLITE_LIBRARIES SQLITE_INCLUDE_DIRS)

0 comments on commit a893f27

Please sign in to comment.