summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Mi <codeminister@publicstatic.de>2014-01-19 23:56:43 (GMT)
committerGregor Mi <codeminister@publicstatic.de>2014-01-20 01:19:25 (GMT)
commit22229f2373c55c74befc1f654854215a9b782862 (patch)
tree48b875af3c36a70cdfcfbab9ac5efca715332b57
parentd6f576adcb836cf62e328f34a1181255e1697a91 (diff)
adapt CMakeLists.txt from frameworks_template, cmake works but does not compile
-rw-r--r--CMakeLists.txt82
-rw-r--r--src/CMakeLists.txt82
-rw-r--r--src/ksane_device_dialog.cpp2
-rw-r--r--src/ksane_viewer.cpp10
-rw-r--r--src/widgets/labeled_gamma.cpp12
5 files changed, 118 insertions, 70 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4867c1f..f0a2510 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
-project(libksane)
+project(KSane)
#message(STATUS "-------------------------------------------")
#message(STATUS "Starting CMake configuration for: libksane")
@@ -10,7 +10,6 @@ find_package(ECM 0.0.9 REQUIRED NO_MODULE)
# ECM setup2 and include find same cmake module (copied from /usr/share/kde4/apps/cmake/modules/FindSane.cmake)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake-modules)
-# TODO: don't know if all these includes are required (copied from ktexteditor)
include(FeatureSummary)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
@@ -27,14 +26,11 @@ ecm_setup_version(
${KF5_VERSION}
VARIABLE_PREFIX LIBKSANE
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/libksane_version.h"
- PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/libksane/version.h.cmake"
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/src/version.h.cmake"
)
-# TODO: Remove these
-remove_definitions(-DQT_NO_CAST_TO_ASCII)
-remove_definitions(-DQT_NO_CAST_FROM_ASCII)
-remove_definitions(-DQT_NO_URL_CAST_FROM_STRING)
-remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
+# Dependencies
+set(REQUIRED_QT_VERSION "5.2.0")
# Required Qt5 components to build this framework
find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets)
@@ -50,19 +46,58 @@ find_package(KF5XmlGui ${KF5_VERSION} REQUIRED)
find_package(KF5Wallet ${KF5_VERSION} REQUIRED)
find_package(KF5WidgetsAddons ${KF5_VERSION} REQUIRED)
+# ...
+
+# Subdirectories
+add_subdirectory(src)
+add_subdirectory(autotests)
+add_subdirectory(tests)
+
+# TODO: Remove these later
+remove_definitions(-DQT_NO_CAST_TO_ASCII)
+remove_definitions(-DQT_NO_CAST_FROM_ASCII)
+remove_definitions(-DQT_NO_URL_CAST_FROM_STRING)
+remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
+
+# Create a Config.cmake and a ConfigVersion.cmake file and install them
+set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KSane")
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/KF5SaneConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/KF5SaneConfig.cmake"
+ INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
+)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/KF5SaneConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/KF5SaneConfigVersion.cmake"
+ DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
+ COMPONENT Devel
+)
+
+install(EXPORT
+ KF5SaneTargets
+ DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
+ FILE KF5SaneTargets.cmake
+ NAMESPACE KF5::
+)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/ksane_version.h"
+ DESTINATION "${INCLUDE_INSTALL_DIR}"
+ COMPONENT Devel
+)
+
# Check if sane API is available.
if (NOT WIN32)
find_package(Sane)
# macro_log_feature(SANE_FOUND "SANE development toolkit" "Scanner Access Now Easy (SANE) development package" "http://www.sane-project.org" TRUE "" "Needed by libksane")
endif (NOT WIN32)
-# Dependencies
-set(REQUIRED_QT_VERSION "5.2.0")
-add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-include_directories (${CMAKE_SOURCE_DIR}
- ${CMAKE_BINARY_DIR}
- ${KDE4_INCLUDES}
- ${CMAKE_CURRENT_BINARY_DIR}/libksane)
+# needed?
+#include_directories (${CMAKE_SOURCE_DIR}
+# ${CMAKE_BINARY_DIR}
+# ${CMAKE_CURRENT_BINARY_DIR}/libksane)
# =======================================================
# Information to update before to release this library.
@@ -105,7 +140,7 @@ SET(KSANE_LIB_SO_VERSION_STRING "${KSANE_LIB_SO_CUR_VERSION}.${KSANE_LIB_SO_REV_
ADD_DEFINITIONS(-DKDE_DEFAULT_DEBUG_AREA=51004)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libksane/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libksane/version.h)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/version.h)
# =======================================================
@@ -118,11 +153,11 @@ ENDIF(WIN32 AND MSVC)
# =======================================================
-IF (SANE_FOUND)
- ADD_SUBDIRECTORY(libksane)
-ELSE (SANE_FOUND)
- ADD_SUBDIRECTORY(ksanetwain)
-ENDIF (SANE_FOUND)
+#IF (SANE_FOUND)
+# # ADD_SUBDIRECTORY(src) # old: was already done above
+#ELSE (SANE_FOUND)
+# ADD_SUBDIRECTORY(ksanetwain)
+#.ENDIF (SANE_FOUND)
IF(NOT WIN32)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libksane.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libksane.pc)
@@ -130,5 +165,6 @@ IF(NOT WIN32)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libksane.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
ENDIF(NOT WIN32)
-feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
-
+if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
+ feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 63c8c04..8621571 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,9 +1,4 @@
-include_directories(${SANE_INCLUDE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/options
- ${CMAKE_CURRENT_SOURCE_DIR}/widgets
-)
-
-set(ksane_LIB_SRCS
+set(ksane_SRCS
widgets/gamma_disp.cpp
widgets/labeled_gamma.cpp
widgets/labeled_checkbox.cpp
@@ -31,51 +26,70 @@ set(ksane_LIB_SRCS
options/ksane_opt_slider.cpp
options/ksane_opt_fslider.cpp
options/ksane_opt_combo.cpp
- )
+)
-add_library(ksane SHARED ${ksane_LIB_SRCS})
+add_library(KF5Sane ${ksane_SRCS})
+generate_export_header(KF5Sane BASE_NAME KSane)
+add_library(KF5::KSane ALIAS KF5Sane)
-target_link_libraries (ksane
- LINK_PRIVATE
- KF5::I18n
- KF5::PrintUtils
- KF5::Wallet
- KF5::WidgetsAddons
- ${SANE_LIBRARY})
+target_include_directories(KF5Sane INTERFACE "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}/KSane>")
-set_target_properties(ksane PROPERTIES VERSION ${KSANE_LIB_SO_VERSION_STRING} SOVERSION ${KSANE_LIB_SO_CUR_VERSION})
+target_link_libraries(KF5Sane
+ PUBLIC
+ Qt5::Core
+ # PRIVATE
+ # KF5::CoreAddons
+ # Other private libs
+ KF5::I18n
+ KF5::PrintUtils
+ KF5::Wallet
+ KF5::WidgetsAddons
+ ${SANE_LIBRARY}
+)
-option(COMPILE_VIEWER_TESTAPP "Compile a small test application for the viewer")
+set_target_properties(KF5Sane
+ PROPERTIES VERSION ${KSANE_VERSION_STRING}
+ SOVERSION ${KSANE_SOVERSION}
+)
+
+option(COMPILE_VIEWER_TESTAPP "Compile a small test application for the viewer")
if (COMPILE_VIEWER_TESTAPP)
message("Compile testapp")
add_executable(viewer_test ksane_viewer.cpp ksane_viewer_test.cpp selectionitem.cpp)
target_link_libraries(viewer_test
LINK_PRIVATE
- KF5::I18n
- KF5::PrintUtils
- KF5::Wallet
- KF5::WidgetsAddons
- ${SANE_LIBRARY})
+ KF5::I18n
+ KF5::PrintUtils
+ KF5::Wallet
+ KF5::WidgetsAddons
+ ${SANE_LIBRARY})
endif()
-install(TARGETS ksane ${INSTALL_TARGETS_DEFAULT_ARGS} )
+# FIXME?
+ecm_generate_headers(
+ KSane_Viewer
+ KSane_Widget
+ # FIXME? more?
-# FIXME: split widget and logic into two components
-install(FILES ksane_widget.h
- libksane_export.h
- ${CMAKE_CURRENT_BINARY_DIR}/version.h
- DESTINATION ${INCLUDE_INSTALL_DIR}/libksane COMPONENT Devel)
+ MODULE_NAME KSane
+ REQUIRED_HEADERS KSane_HEADERS
+)
+
+# Install files
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KSane DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
# FIXME KF5: KDE4_INSTALL_ICONS
#KDE4_INSTALL_ICONS(${ICON_INSTALL_DIR})
-
-configure_file(
- ../KSaneConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake @ONLY
+install(TARGETS KF5Sane
+ EXPORT KF5SaneTargets
+ ${INSTALL_TARGETS_DEFAULT_ARGS}
)
-install(
- FILES ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake
- DESTINATION ${LIB_INSTALL_DIR}/cmake/KSane
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/ksane_export.h
+ ${KSane_HEADERS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/KSane
+ COMPONENT Devel
)
diff --git a/src/ksane_device_dialog.cpp b/src/ksane_device_dialog.cpp
index 8635c97..4c0bfd6 100644
--- a/src/ksane_device_dialog.cpp
+++ b/src/ksane_device_dialog.cpp
@@ -165,7 +165,7 @@ void KSaneDeviceDialog::updateDevicesList()
QRadioButton *b = new QRadioButton(this);
b->setObjectName(list[i].name);
b->setToolTip(list[i].name);
- b->setText(QString("%1 : %2\n%3")
+ b->setText(QString(QLatin1String("%1 : %2\n%3"))
.arg(list[i].vendor)
.arg(list[i].model)
.arg(list[i].name));
diff --git a/src/ksane_viewer.cpp b/src/ksane_viewer.cpp
index 0d6f9d6..3eaa248 100644
--- a/src/ksane_viewer.cpp
+++ b/src/ksane_viewer.cpp
@@ -128,19 +128,19 @@ KSaneViewer::KSaneViewer(QImage * img, QWidget *parent) : QGraphicsView(parent),
d->selectionList.clear();
// create context menu
- d->zoomInAction = new QAction(QIcon::fromTheme("zoom-in"), i18n("Zoom In"), this);
+ d->zoomInAction = new QAction(QIcon::fromTheme(QLatin1String("zoom-in")), i18n("Zoom In"), this);
connect(d->zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
- d->zoomOutAction = new QAction(QIcon::fromTheme("zoom-out"), i18n("Zoom Out"), this);
+ d->zoomOutAction = new QAction(QIcon::fromTheme(QLatin1String("zoom-out")), i18n("Zoom Out"), this);
connect(d->zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
- d->zoomSelAction = new QAction(QIcon::fromTheme("zoom-fit-best"), i18n("Zoom to Selection"), this);
+ d->zoomSelAction = new QAction(QIcon::fromTheme(QLatin1String("zoom-fit-best")), i18n("Zoom to Selection"), this);
connect(d->zoomSelAction, SIGNAL(triggered()), this, SLOT(zoomSel()));
- d->zoom2FitAction = new QAction(QIcon::fromTheme("document-preview"), i18n("Zoom to Fit"), this);
+ d->zoom2FitAction = new QAction(QIcon::fromTheme(QLatin1String("document-preview")), i18n("Zoom to Fit"), this);
connect(d->zoom2FitAction, SIGNAL(triggered()), this, SLOT(zoom2Fit()));
- d->clrSelAction = new QAction(QIcon::fromTheme("edit-clear"), i18n("Clear Selections"), this);
+ d->clrSelAction = new QAction(QIcon::fromTheme(QLatin1String("edit-clear")), i18n("Clear Selections"), this);
connect(d->clrSelAction, SIGNAL(triggered()), this, SLOT(clearSelections()));
addAction(d->zoomInAction);
diff --git a/src/widgets/labeled_gamma.cpp b/src/widgets/labeled_gamma.cpp
index 1a4fa24..f3cf775 100644
--- a/src/widgets/labeled_gamma.cpp
+++ b/src/widgets/labeled_gamma.cpp
@@ -6,6 +6,7 @@
* Description : Sane interface for KDE
*
* Copyright (C) 2007-2011 by Kare Sars <kare.sars@iki .fi>
+ * Copyright (C) 2014 by Gregor Mitsch: port to KDE5 frameworks
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -29,14 +30,11 @@
#include "labeled_gamma.h"
#include "labeled_gamma.moc"
-// C++ includes
-#include <cmath>
-
-// Qt includes
#include <QGroupBox>
-// KDE includes
-#include <klocale.h>
+#include <klocalizedstring.h>
+
+#include <cmath>
namespace KSaneIface
{
@@ -126,7 +124,7 @@ void LabeledGamma::setValues(const QString &values)
int gam;
bool ok = true;
- gammaValues = values.split(':');
+ gammaValues = values.split(QLatin1Char(':'));
bri = gammaValues.at(0).toInt(&ok);
if (ok) con = gammaValues.at(1).toInt(&ok);
if (ok) gam = gammaValues.at(2).toInt(&ok);