mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
cmake: consolidate non-linux library handling
Move the handling to the top-level, adding it _once_ to EXTRA_LIBS.
Thus avoiding some duplication across the board.
Note that final handling varies a bit, namely:
- OpenBSD/intl should be handled via the existing cmake/FindGettext.cmake
- Darwin/resolv should not be needed since commit e98a32373 ("core: check
if res_init requires linking with libresolv")
- the backtrace/execinfo handling has been consolidated and moved
In the unlikely case of unwanted over-linking, the platforms can add
`-Wl,--as-needed` to their linker flags. Something which is strongly
encouraged and has been the default across multiple (linux) distros for
years.
Alternatively, if move quirks are needed they should be handled in a
single place.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
committed by
Sébastien Helleu
parent
fc6003c74e
commit
323ab8810e
@@ -311,6 +311,25 @@ else()
|
||||
add_custom_target(translations COMMAND true)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
find_library(EXECINFO_LIB_PATH execinfo /usr/local/lib)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${EXECINFO_LIB_PATH}")
|
||||
check_function_exists(backtrace HAVE_BACKTRACE)
|
||||
list(APPEND EXTRA_LIBS "execinfo")
|
||||
else()
|
||||
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "network")
|
||||
else()
|
||||
list(APPEND EXTRA_LIBS "pthread")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
|
||||
list(APPEND EXTRA_LIBS "socket" "nsl")
|
||||
endif()
|
||||
|
||||
list(APPEND EXTRA_LIBS "m")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -81,14 +81,6 @@ set(LIB_CORE_SRC
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(flock "sys/file.h" HAVE_FLOCK)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
find_library(EXECINFO_LIB_PATH execinfo /usr/local/lib)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${EXECINFO_LIB_PATH}")
|
||||
check_function_exists(backtrace HAVE_BACKTRACE)
|
||||
else()
|
||||
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ZSTD)
|
||||
include_directories(${LIBZSTD_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
@@ -21,22 +21,6 @@
|
||||
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND HAVE_BACKTRACE)
|
||||
list(APPEND EXTRA_LIBS "execinfo")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
|
||||
list(APPEND EXTRA_LIBS "socket" "nsl")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "network")
|
||||
endif()
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "pthread")
|
||||
endif()
|
||||
|
||||
if(ENABLE_NCURSES)
|
||||
subdirs(normal)
|
||||
endif()
|
||||
|
||||
@@ -40,27 +40,6 @@ if(NOT CYGWIN)
|
||||
add_definitions(-fPIC)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND HAVE_BACKTRACE)
|
||||
list(APPEND EXTRA_LIBS "execinfo")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
|
||||
list(APPEND EXTRA_LIBS "socket" "nsl")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "network")
|
||||
endif()
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "pthread")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# link with resolv lib on macOS
|
||||
list(APPEND EXTRA_LIBS "resolv")
|
||||
endif()
|
||||
|
||||
list(APPEND FUZZ_TARGET_LINK
|
||||
weechat_core
|
||||
weechat_plugins
|
||||
|
||||
@@ -206,17 +206,6 @@ endif()
|
||||
|
||||
add_library(weechat_unit_tests_plugins MODULE ${LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC})
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
||||
list(APPEND EXTRA_LIBS "intl")
|
||||
if(HAVE_BACKTRACE)
|
||||
list(APPEND EXTRA_LIBS "execinfo")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
||||
list(APPEND EXTRA_LIBS "pthread")
|
||||
endif()
|
||||
|
||||
# binary to run tests
|
||||
set(WEECHAT_TESTS_SRC
|
||||
tests.cpp tests.h
|
||||
|
||||
Reference in New Issue
Block a user