summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2024-03-26 07:43:03 -0400
committerAustin S. Hemmelgarn <ahferroin7@gmail.com>2024-03-27 09:30:48 -0400
commitf7e2c07e666903db40e8099dfd09501662f22b16 (patch)
tree7cad6eb2b94bd0dc9db46728e49f2a847a6dbf91
parente526d03f756a4251ac6ed267a77e942a4dfc62a6 (diff)
Assorted macOS build fixes. (#17216)
* Use zlib provided by the system itself on macOS. Searching for it with find_package() should always work on macOS since it will find the system copy, which is always going to be there. * Use native libuuid on macOS. Much like zlib, macOS provides a libuuid implementation that (should) work for us, so just use that instead of fighting with brew to find one. * Don’t prepend system include paths. * Skip Linux-specific checks on macOS. This isn’t technically broken, but not making these checks makes debugging of the build system easier. * Minor CMake restructure. (cherry picked from commit 7da059a24fa3b7e9e8d03ee824b6a93a33ba9a23)
-rw-r--r--CMakeLists.txt43
-rw-r--r--packaging/cmake/Modules/NetdataDetectSystemd.cmake54
2 files changed, 56 insertions, 41 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b8b938382..43b279c2d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1477,8 +1477,10 @@ set_source_files_properties(JudyLTables.c PROPERTIES COMPILE_OPTIONS "-I${CMAKE_
# build libnetdata
#
-include(NetdataDetectSystemd)
-detect_systemd()
+if(LINUX)
+ include(NetdataDetectSystemd)
+ detect_systemd()
+endif()
add_library(libnetdata STATIC ${LIBNETDATA_FILES})
@@ -1537,10 +1539,16 @@ endif()
netdata_add_libyaml_to_target(libnetdata)
# zlib
-pkg_check_modules(ZLIB REQUIRED zlib)
-target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
-target_compile_definitions(libnetdata PUBLIC ${ZLIB_CFLAGS_OTHER})
-target_link_libraries(libnetdata PUBLIC ${ZLIB_LDFLAGS})
+if(MACOS)
+ find_package(ZLIB REQUIRED)
+ target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
+ target_link_libraries(libnetdata PUBLIC ZLIB::ZLIB)
+else()
+ pkg_check_modules(ZLIB REQUIRED zlib)
+ target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
+ target_compile_definitions(libnetdata PUBLIC ${ZLIB_CFLAGS_OTHER})
+ target_link_libraries(libnetdata PUBLIC ${ZLIB_LDFLAGS})
+endif()
# lz4 - try to find a version that is compatible with streaming compression
# otherwise pick whichever one we can find to support dbengine but don't set
@@ -1569,16 +1577,21 @@ endif()
pkg_check_modules(LIBBROTLI libbrotlidec libbrotlienc libbrotlicommon)
if(LIBBROTLI_FOUND)
set(ENABLE_BROTLI On)
- target_include_directories(libnetdata BEFORE PUBLIC ${LIBBROTLI_INCLUDE_DIRS})
+ target_include_directories(libnetdata PUBLIC ${LIBBROTLI_INCLUDE_DIRS})
target_compile_definitions(libnetdata PUBLIC ${LIBBROTLI_CFLAGS_OTHER})
target_link_libraries(libnetdata PUBLIC ${LIBBROTLI_LDFLAGS})
endif()
# uuid
-pkg_check_modules(UUID REQUIRED uuid)
-target_include_directories(libnetdata BEFORE PUBLIC ${UUID_INCLUDE_DIRS})
-target_compile_definitions(libnetdata PUBLIC ${UUID_CFLAGS_OTHER})
-target_link_libraries(libnetdata PUBLIC ${UUID_LDFLAGS})
+if(MACOS)
+ # UUID functionality is part of the system libraries here, so no extra
+ # stuff needed.
+else()
+ pkg_check_modules(UUID REQUIRED uuid)
+ target_include_directories(libnetdata BEFORE PUBLIC ${UUID_INCLUDE_DIRS})
+ target_compile_definitions(libnetdata PUBLIC ${UUID_CFLAGS_OTHER})
+ target_link_libraries(libnetdata PUBLIC ${UUID_LDFLAGS})
+endif()
# uv
pkg_check_modules(LIBUV REQUIRED libuv)
@@ -1597,9 +1610,11 @@ target_compile_options(libnetdata PUBLIC ${OPENSSL_CFLAGS_OTHER})
target_link_libraries(libnetdata PUBLIC ${OPENSSL_LDFLAGS})
# mnl
-pkg_check_modules(MNL libmnl)
-if(MNL_FOUND)
- set(HAVE_LIBMNL True)
+if(NOT MACOS)
+ pkg_check_modules(MNL libmnl)
+ if(MNL_FOUND)
+ set(HAVE_LIBMNL True)
+ endif()
endif()
#
diff --git a/packaging/cmake/Modules/NetdataDetectSystemd.cmake b/packaging/cmake/Modules/NetdataDetectSystemd.cmake
index 5c0e6e09e5..ecac7aaf84 100644
--- a/packaging/cmake/Modules/NetdataDetectSystemd.cmake
+++ b/packaging/cmake/Modules/NetdataDetectSystemd.cmake
@@ -4,39 +4,39 @@
# SPDX-License-Identifier: GPL-3.0-or-later
macro(detect_systemd)
- find_library(SYSTEMD_LIBRARY NAMES systemd)
+ find_library(SYSTEMD_LIBRARY NAMES systemd)
- set(ENABLE_DSYSTEMD_DBUS NO)
- pkg_check_modules(SYSTEMD libsystemd)
+ set(ENABLE_DSYSTEMD_DBUS NO)
+ pkg_check_modules(SYSTEMD libsystemd)
- if(SYSTEMD_FOUND)
- set(CMAKE_REQUIRED_LIBRARIES_BEFORE_SYSTEMD "${CMAKE_REQUIRED_LIBRARIES}")
- set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${SYSTEMD_LIBRARIES}")
+ if(SYSTEMD_FOUND)
+ set(CMAKE_REQUIRED_LIBRARIES_BEFORE_SYSTEMD "${CMAKE_REQUIRED_LIBRARIES}")
+ set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${SYSTEMD_LIBRARIES}")
- check_c_source_compiles("
- #include <systemd/sd-journal.h>
+ check_c_source_compiles("
+ #include <systemd/sd-journal.h>
- int main() {
- int x = SD_JOURNAL_OS_ROOT;
- return 0;
- }" HAVE_SD_JOURNAL_OS_ROOT)
+ int main() {
+ int x = SD_JOURNAL_OS_ROOT;
+ return 0;
+ }" HAVE_SD_JOURNAL_OS_ROOT)
- check_symbol_exists(SD_JOURNAL_OS_ROOT "systemd/sd-journal.h" HAVE_SD_JOURNAL_OS_ROOT)
- check_symbol_exists(sd_journal_open_files_fd "systemd/sd-journal.h" HAVE_SD_JOURNAL_OPEN_FILES_FD)
- check_symbol_exists(sd_journal_restart_fields "systemd/sd-journal.h" HAVE_SD_JOURNAL_RESTART_FIELDS)
- check_symbol_exists(sd_journal_get_seqnum "systemd/sd-journal.h" HAVE_SD_JOURNAL_GET_SEQNUM)
+ check_symbol_exists(SD_JOURNAL_OS_ROOT "systemd/sd-journal.h" HAVE_SD_JOURNAL_OS_ROOT)
+ check_symbol_exists(sd_journal_open_files_fd "systemd/sd-journal.h" HAVE_SD_JOURNAL_OPEN_FILES_FD)
+ check_symbol_exists(sd_journal_restart_fields "systemd/sd-journal.h" HAVE_SD_JOURNAL_RESTART_FIELDS)
+ check_symbol_exists(sd_journal_get_seqnum "systemd/sd-journal.h" HAVE_SD_JOURNAL_GET_SEQNUM)
- check_symbol_exists(sd_bus_default_system "systemd/sd-bus.h" HAVE_SD_BUS_DEFAULT_SYSTEM)
- check_symbol_exists(sd_bus_call_method "systemd/sd-bus.h" HAVE_SD_BUS_CALL_METHOD)
- check_symbol_exists(sd_bus_message_enter_container "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_ENTER_CONTAINER)
- check_symbol_exists(sd_bus_message_read "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_READ)
- check_symbol_exists(sd_bus_message_exit_container "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_EXIT_CONTAINER)
+ check_symbol_exists(sd_bus_default_system "systemd/sd-bus.h" HAVE_SD_BUS_DEFAULT_SYSTEM)
+ check_symbol_exists(sd_bus_call_method "systemd/sd-bus.h" HAVE_SD_BUS_CALL_METHOD)
+ check_symbol_exists(sd_bus_message_enter_container "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_ENTER_CONTAINER)
+ check_symbol_exists(sd_bus_message_read "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_READ)
+ check_symbol_exists(sd_bus_message_exit_container "systemd/sd-bus.h" HAVE_SD_BUS_MESSAGE_EXIT_CONTAINER)
- set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_BEFORE_SYSTEMD}")
+ set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_BEFORE_SYSTEMD}")
- set(HAVE_SYSTEMD True)
- if(HAVE_SD_BUS_DEFAULT_SYSTEM AND HAVE_SD_BUS_CALL_METHOD AND HAVE_SD_BUS_MESSAGE_ENTER_CONTAINER AND HAVE_SD_BUS_MESSAGE_READ AND HAVE_SD_BUS_MESSAGE_EXIT_CONTAINER)
- set(ENABLE_SYSTEMD_DBUS YES)
- endif()
- endif()
+ set(HAVE_SYSTEMD True)
+ if(HAVE_SD_BUS_DEFAULT_SYSTEM AND HAVE_SD_BUS_CALL_METHOD AND HAVE_SD_BUS_MESSAGE_ENTER_CONTAINER AND HAVE_SD_BUS_MESSAGE_READ AND HAVE_SD_BUS_MESSAGE_EXIT_CONTAINER)
+ set(ENABLE_SYSTEMD_DBUS YES)
+ endif()
+ endif()
endmacro()