Skip to content

Commit

Permalink
cmake: improve building on mac
Browse files Browse the repository at this point in the history
previously some libraries weren't found on MacOS if they weren't
force-linked using brew link.
This patch makes cmake discover the libaries in their respective
directories under /usr/local/opt/ so linking is not required anymore.

We also change the linking with homebrew libraries to be static instead
of dynamic so you don't need to install homebrew to use bareos.

Lastly this fixes a build issue when you have a case-sensitive
filesystem.
  • Loading branch information
arogge committed Aug 29, 2019
1 parent b0e62a1 commit 0d17f2b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/CMakeLists.txt
Expand Up @@ -138,7 +138,9 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#set(CMAKE_INCLUDE_PATH "${OPENSSL_INCLUDE_DIR}:${CMAKE_INCLUDE_PATH}")
set(CMAKE_INCLUDE_PATH "/usr/local/opt/:${CMAKE_INCLUDE_PATH}")
link_directories(/usr/local/lib)
link_libraries(intl)

include_directories(/usr/local/opt/gettext/include)
link_libraries(/usr/local/opt/gettext/lib/libintl.a iconv "-framework CoreFoundation")
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}-${BAREOS_FULL_VERSION}")
ENDIF()

Expand Down
3 changes: 3 additions & 0 deletions core/cmake/BareosFindAllLibraries.cmake
Expand Up @@ -39,6 +39,9 @@ endif()

INCLUDE(CMakeUserFindMySQL)

IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(OPENSSL_USE_STATIC_LIBS 1)
ENDIF()
INCLUDE(FindOpenSSL)

if (${OPENSSL_FOUND})
Expand Down
12 changes: 8 additions & 4 deletions core/cmake/FindReadline.cmake
Expand Up @@ -10,10 +10,14 @@ find_path(Readline_INCLUDE_DIR
)

# Search for library
find_library(Readline_LIBRARY
NAMES readline
HINTS ${Readline_ROOT_DIR}/lib
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(Readline_LIBRARY /usr/local/opt/readline/lib/libreadline.a ncurses)
else()
find_library(Readline_LIBRARY
NAMES readline
HINTS ${Readline_ROOT_DIR}/lib
)
endif()
# Conditionally set READLINE_FOUND value
if(Readline_INCLUDE_DIR AND Readline_LIBRARY
AND Ncurses_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion core/platforms/darwin/CMakeLists.txt
Expand Up @@ -57,4 +57,4 @@ SET(CPACK_POSTFLIGHT_UNSPECIFIED_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/resources/pos
SET(CPACK_PREFLIGHT_BAREOS_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/resources/preinstall")
SET(CPACK_POSTFLIGHT_BAREOS_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/resources/postinstall")

INCLUDE(CPACK)
INCLUDE(CPack)

0 comments on commit 0d17f2b

Please sign in to comment.