From 6a1ea1f73073710ee4ce79f54a40071b51d78ff3 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Fri, 11 Dec 2020 17:50:13 +0100
Subject: [PATCH] Modernize CMake machinery regarding qcustomplot

---
 GUI/coregui/CMakeLists.txt                |  3 +--
 ThirdParty/GUI/qcustomplot/CMakeLists.txt | 21 +++------------------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt
index b3b40ef7ea6..309cbfa5dba 100644
--- a/GUI/coregui/CMakeLists.txt
+++ b/GUI/coregui/CMakeLists.txt
@@ -94,11 +94,9 @@ set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE)
 # --- dependencies ---------
 target_include_directories(${library_name} PUBLIC
     ${CMAKE_SOURCE_DIR}/ThirdParty/GUI # for qt-manhattan-style
-    ${qcustomplot_INCLUDE_DIRS}
     ${CMAKE_SOURCE_DIR})
 target_link_libraries(${library_name}
     ${ManhattanStyle_LIBRARY}
-    ${qcustomplot_LIBRARY}
     ${BornAgainCore_LIBRARY}
     ${ba3d_LIBRARY}
     Qt5::Widgets
@@ -107,6 +105,7 @@ target_link_libraries(${library_name}
     Qt5::Designer
     Qt5::PrintSupport
     Qt5::Network
+    qcustomplot
 )
 
 # --- Installation ---------
diff --git a/ThirdParty/GUI/qcustomplot/CMakeLists.txt b/ThirdParty/GUI/qcustomplot/CMakeLists.txt
index 21d5d4ac20e..b22e30b6599 100644
--- a/ThirdParty/GUI/qcustomplot/CMakeLists.txt
+++ b/ThirdParty/GUI/qcustomplot/CMakeLists.txt
@@ -3,22 +3,7 @@
 ############################################################################
 set(library_name qcustomplot)
 
-set(source_files qcustomplot.h qcustomplot.cpp)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_AUTOMOC ON)
-
-add_library(
-    ${library_name}
-    STATIC
-    ${source_files} ${mocfiles}
-)
-set(${library_name}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
-set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE)
-
-target_link_libraries(${library_name} ${Qt5Widgets_LIBRARIES})
-
-target_link_libraries(${library_name}
-    Qt5::Widgets
-    Qt5::PrintSupport
-)
+add_library(${library_name} STATIC qcustomplot.h qcustomplot.cpp)
+target_link_libraries(${library_name} PUBLIC Qt5::Widgets Qt5::PrintSupport)
+target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_LIST_DIR})
-- 
GitLab