From 0559e4683ec72d7608560414d8d6797f83c74ea7 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Mar 2024 17:17:45 -0500 Subject: [PATCH] src/CMakeLists.txt: link libplfit against $MATH_LIBRARY The libplfit library makes use of several math functions (exp, log, ...) , and so should be linked to libm directly when libm is required for those functions. If it is not, then compilation may succeed leaving the resulting library underlinked. This can lead to errors like, test_discrete: symbol lookup error: .../src/libplfit.so.0: undefined symbol: log when linking with lld and LDFLAGS="Wl,--as-needed". (The error above comes from plfit's own test suite.) Gentoo-bug: https://bugs.gentoo.org/926433 --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fbfb3e8..3dd50fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ set(PLFIT_CORE_SRCS error.c gss.c kolmogorov.c lbfgs.c mt.c platform.c plfit.c o add_library(plfit ${PLFIT_CORE_SRCS}) target_include_directories(plfit PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(plfit PROPERTIES SOVERSION 0) +target_link_libraries(plfit ${MATH_LIBRARY}) if(PLFIT_USE_OPENMP AND OPENMP_FOUND) target_link_libraries(plfit OpenMP::OpenMP_C) -- 2.43.0