From fc7b00562c52c9cbb1394fc234b70554549863b5 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Fri, 9 Jul 2021 16:49:40 +0100 Subject: [PATCH] build: require CMake 3.12, resolve circular dependency In order to resolve the circular dependency, we need to annotate the respective static libraries as "object" libraries. This requires cmake 3.12, where Debian 10 (old old stable) and Ubuntu 20.04 have 3.13 and 3.16 respectively. Signed-off-by: Emil Velikov --- CMakeLists.txt | 6 ++---- src/core/CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 2 +- src/gui/curses/headless/CMakeLists.txt | 2 -- src/gui/curses/normal/CMakeLists.txt | 8 ++++++-- tests/CMakeLists.txt | 2 -- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c99273c6f..8316b2339 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ # along with WeeChat. If not, see . # -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(weechat C) @@ -242,14 +242,12 @@ endif() # Check for CURL find_package(CURL REQUIRED) -# weechat_gui_common MUST be the first lib in the list -set(STATIC_LIBS weechat_gui_common) +set(STATIC_LIBS weechat_plugins) find_library(DL_LIBRARY NAMES dl PATHS /lib /usr/lib /usr/libexec /usr/local/lib /usr/local/libexec ) -list(APPEND STATIC_LIBS weechat_plugins) if(DL_LIBRARY) string(REGEX REPLACE "/[^/]*$" "" DL_LIBRARY_PATH "${DL_LIBRARY}") set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${DL_LIBRARY_PATH}") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 5c88708c3..c2944d1c5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -100,6 +100,6 @@ if(ENABLE_CJSON) endif() include_directories("${CMAKE_BINARY_DIR}") -add_library(weechat_core STATIC ${LIB_CORE_SRC}) +add_library(weechat_core OBJECT ${LIB_CORE_SRC}) target_link_libraries(weechat_core coverage_config) add_dependencies(weechat_core version_git) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index dffab6415..6ccbc254b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -43,7 +43,7 @@ set(LIB_GUI_COMMON_SRC ) include_directories("${CMAKE_BINARY_DIR}") -add_library(weechat_gui_common STATIC ${LIB_GUI_COMMON_SRC}) +add_library(weechat_gui_common OBJECT ${LIB_GUI_COMMON_SRC}) target_link_libraries(weechat_gui_common coverage_config) list(APPEND STATIC_LIBS weechat_gui_common) diff --git a/src/gui/curses/headless/CMakeLists.txt b/src/gui/curses/headless/CMakeLists.txt index cd79c32f4..6f65ccbfd 100644 --- a/src/gui/curses/headless/CMakeLists.txt +++ b/src/gui/curses/headless/CMakeLists.txt @@ -55,9 +55,7 @@ add_dependencies(${EXECUTABLE} weechat_ncurses_fake ) -# Due to circular references, we must link two times with libweechat_core.a and libweechat_gui_common.a target_link_libraries(${EXECUTABLE} - ${STATIC_LIBS} weechat_gui_headless weechat_ncurses_fake ${EXTRA_LIBS} diff --git a/src/gui/curses/normal/CMakeLists.txt b/src/gui/curses/normal/CMakeLists.txt index 16483a219..3fa7436b0 100644 --- a/src/gui/curses/normal/CMakeLists.txt +++ b/src/gui/curses/normal/CMakeLists.txt @@ -58,8 +58,12 @@ add_dependencies(${EXECUTABLE} weechat_gui_curses_normal) list(APPEND EXTRA_LIBS ${NCURSES_LIBRARY}) -# Due to circular references, we must link two times with libweechat_core.a and libweechat_gui_common.a -target_link_libraries(${EXECUTABLE} ${STATIC_LIBS} weechat_gui_curses_normal ${EXTRA_LIBS} ${STATIC_LIBS} coverage_config) +target_link_libraries(${EXECUTABLE} + weechat_gui_curses_normal + ${EXTRA_LIBS} + ${STATIC_LIBS} + coverage_config +) # Create a symbolic link weechat-curses -> weechat # This link is created for compatibility with old versions on /upgrade. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d6842e417..a92df7481 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -226,8 +226,6 @@ target_link_libraries(tests weechat_gui_headless weechat_ncurses_fake weechat_unit_tests_core - # due to circular references, we must link two times with libweechat_core.a - weechat_core ${EXTRA_LIBS} ${CURL_LIBRARIES} ${ZLIB_LIBRARY}