Skip to content

Commit

Permalink
Rework CMake files.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Nov 27, 2024
1 parent eb593c1 commit 4a2a34c
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 58 deletions.
80 changes: 45 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,59 @@ qt_standard_project_setup()

include(qwt_setup.cmake)

set(SOURCES
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

set(${PROJECT_NAME}_SOURCES
src/qwtble_global.h
src/BasicDataPlot.h
src/BasicDataPlot.cpp
src/YAxisNumberPicker.h
src/YAxisNumberPicker.cpp
src/GroupPlot.h
src/GroupPlot.cpp
src/HistogramPlot.h
src/HistogramPlot.cpp
src/XYAxisNumberPicker.h
src/XYAxisNumberPicker.cpp
src/XDateYAxisNumberPicker.h
src/XDateYAxisNumberPicker.cpp
src/NotchedMarker.h
src/NotchedMarker.cpp
src/Picker.h
src/Picker.cpp
src/PlotBase.h
src/PlotBase.cpp
src/PlotMagnifier.h
src/PlotMagnifier.cpp
src/QuantilesPlot.h
src/QuantilesPlot.cpp
src/StringsScaleDraw.h
src/StringsScaleDraw.cpp
src/Quantiles.h
src/Quantiles.cpp
src/QwtBleUtilities.h
src/QwtBleUtilities.cpp
src/GroupPlotUI.h
src/GroupPlotUI.cpp
src/HistogramPlotUI.h
src/HistogramPlotUI.cpp
src/Utilities.h
src/Utilities.cpp
)

set(HEADERS
set(PUBLIC_HEADERS
src/qwtble_global.h
src/BasicDataPlot.h
src/YAxisNumberPicker.h
src/GroupPlot.h
src/HistogramPlot.h
src/XYAxisNumberPicker.h
src/XDateYAxisNumberPicker.h
src/NotchedMarker.h
src/Picker.h
src/PlotBase.h
src/PlotMagnifier.h
src/QuantilesPlot.h
src/StringsScaleDraw.h
src/Quantiles.h
src/QwtBleUtilities.h
src/NotchedMarker.h
src/GroupPlotUI.h
src/HistogramPlotUI.h
src/Utilities.h
)

set(UI
Expand All @@ -69,29 +83,32 @@ set(UI
)
source_group("UI Files" FILES ${UI})

add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS} ${UI})
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${UI})

set(PUBLIC_HEADERS
src/qwtble_global.h
src/BasicDataPlot.h
src/GroupPlot.h
src/HistogramPlot.h
src/PlotBase.h
src/QuantilesPlot.h
src/Quantiles.h
src/QwtBleUtilities.h
src/NotchedMarker.h
src/GroupPlotUI.h
src/HistogramPlotUI.h
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "${PUBLIC_HEADERS}"
)
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "${PUBLIC_HEADERS}")

configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)

target_include_directories(${PROJECT_NAME} PUBLIC src)
target_compile_definitions(${PROJECT_NAME} PRIVATE QWTBLE_LIBRARY)

install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
if (WIN32)
Expand All @@ -100,13 +117,6 @@ else()
target_link_libraries(${PROJECT_NAME} PRIVATE qwt)
endif()

target_compile_definitions(${PROJECT_NAME} PRIVATE QWTBLE_LIBRARY)

include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_subdirectory(examples)

enable_testing()
Expand Down
19 changes: 7 additions & 12 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
project(examples)
SET(PROJECT_TEST ${PROJECT_NAME}-example)

set(SOURCES
include_directories(${CMAKE_SOURCE_DIR})

set(${PROJECT_TEST}_SOURCES
example.cpp
)

add_executable(examples ${SOURCES})

target_link_libraries(examples PRIVATE Qt6::Core Qt6::Widgets qwtble)

if (WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE optimized qwt debug qwtd)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE qwt)
endif()

add_executable(${PROJECT_TEST} ${${PROJECT_TEST}_SOURCES})
target_link_libraries(${PROJECT_TEST} PRIVATE qwtble Qt6::Test Qt6::Widgets)

add_test(NAME ${PROJECT_TEST} COMMAND ${PROJECT_TEST})
17 changes: 9 additions & 8 deletions examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
#include <QVBoxLayout>
#include <QWidget>

#include <BasicDataPlot.h>
#include <GroupPlot.h>
#include <GroupPlotUI.h>
#include <HistogramPlot.h>
#include <HistogramPlotUI.h>
#include <PlotBase.h>
#include <QuantilesPlot.h>
#include <QwtBleUtilities.h>
#include <src/BasicDataPlot.h>
#include <src/GroupPlot.h>
#include <src/GroupPlotUI.h>
#include <src/HistogramPlot.h>
#include <src/HistogramPlotUI.h>
#include <src/PlotBase.h>
#include <src/QuantilesPlot.h>
#include <src/QwtBleUtilities.h>
#include <src/Quantiles.h>

static QVector<QVector<double>> exampleValues{
{3.5, 6.7, 4.7, 6.6, 3., 4.9},
Expand Down
12 changes: 12 additions & 0 deletions qwtble.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires:
Libs: -L${libdir} -l@PROJECT_NAME@
Cflags: -I${includedir}
3 changes: 2 additions & 1 deletion test/GroupPlotUITest.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "GroupPlotUITest.h"

#include <GroupPlotUI.h>
#include <QComboBox>
#include <QSignalSpy>
#include <QTest>

#include <src/GroupPlotUI.h>

void GroupPlotUITest::testTraitChange()
{
const GroupPlotUI groupPlotUI({{"a", 0}, {"b", 1}, {"c", 2}});
Expand Down
3 changes: 2 additions & 1 deletion test/QuantilesTest.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "QuantilesTest.h"

#include <Quantiles.h>
#include <QRegularExpression>
#include <QTest>

#include <src/Quantiles.h>

void QuantilesTest::testToolTip()
{
Quantiles quantiles;
Expand Down
2 changes: 1 addition & 1 deletion test/UtilitiesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <QTest>

#include "QwtBleUtilities.h"
#include <src/QwtBleUtilities.h>

void UtilitiesTest::testStringFromDays()
{
Expand Down

0 comments on commit 4a2a34c

Please sign in to comment.