From b83de34310d13920e1be5e980d0774f35c1d9a2a Mon Sep 17 00:00:00 2001
From: Heiko Becker <heiko.becker@kde.org>
Date: Wed, 31 May 2023 21:19:12 +0200
Subject: [PATCH] Fix build without INDI

Without INDI present I get the following error:

"x86_64-pc-linux-gnu-ld: ../lib/libKStarsLib.a(robuststatistics.cpp.o):
in function `Mathematics::GSLHelpers::gslMedianFromSortedData(
double const*, unsigned long, unsigned long)':
.../work/kstars-3.6.5/kstars/auxiliary/gslhelpers.h:306: undefined
reference to `gsl_stats_median_from_sorted_data'"

That is the case because Mathematics::RobustStatistics is used
unconditionally, which pulls in gslhelpers and the need to link with
GSL.

Also drop the duplicate linking of KF5::Notifications, KStarsLib already
links to it in the NOT ANDROID case.
---
 kstars/CMakeLists.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 747ce79a95..b755be5737 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -1169,6 +1169,8 @@ set(kstars_SRCS ${kstars_SRCS} ${fits2_SRCS} ${sep_SRCS} ${gpg_SRCS} ${hough_SRC
 set(kstarslite_SRCS ${kstarslite_SRCS} ${fits_klite_SRCS} ${sep_SRCS} ${hough_SRCS} ${fits2_klite_SRCS} ${kstarslite_libtess_SRC})
 
 IF (NOT ANDROID)
+    # GSL
+    find_package(GSL REQUIRED)
     qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.xml kstars.h KStars)
     qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.SimClock.xml simclock.h SimClock)
     qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.FOV.xml fov.h FOV)
@@ -1243,6 +1245,7 @@ IF (NOT ANDROID)
         Qt5::WebSockets
         ${ZLIB_LIBRARIES}
         Eigen3::Eigen
+        GSL::gsl
         )
 
     if (Qt5Keychain_FOUND)
@@ -1313,10 +1316,7 @@ if(INDI_FOUND)
     ## Linux + MacOS Lite: Requires INDI Qt5 Client
     ## Android: Requires INDI Qt5 Client built for Android
     if (NOT ANDROID)
-        # GSL
-        find_package(GSL REQUIRED)
-        include_directories(${GSL_INCLUDE_DIRS})
-        target_link_libraries(KStarsLib ${GSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} KF5::Notifications)
+        target_link_libraries(KStarsLib ${CMAKE_THREAD_LIBS_INIT})
         # StellarSolver
         target_link_libraries(KStarsLib StellarSolver::stellarsolver)
     endif ()
-- 
GitLab

