aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Mi <codeminister@publicstatic.de>2014-01-19 16:34:09 (GMT)
committerGregor Mi <codeminister@publicstatic.de>2014-01-19 16:46:17 (GMT)
commit5b8884e016786bcef2ae6430ca612ed2290f1307 (patch)
tree95285ef6843be07a8a70df98f70c9f2bb922d4ea
parent81aaa6ae2476d1dbbe423a20a79cf73786741412 (diff)
port to frameworks: step 1: compiles (but does not link)
-rw-r--r--CMakeLists.txt78
-rw-r--r--cmake-modules/FindSane.cmake21
-rw-r--r--libksane/CMakeLists.txt44
-rw-r--r--libksane/ksane.h1
-rw-r--r--libksane/ksane_preview_thread.cpp3
-rw-r--r--libksane/ksane_scan_thread.cpp3
-rw-r--r--libksane/ksane_widget.cpp3
-rw-r--r--libksane/splittercollapser.cpp4
8 files changed, 113 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb0c562..a75c991 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,21 +1,64 @@
-PROJECT(libksane)
-
-MESSAGE(STATUS "----------------------------------------------------------------------------------")
-MESSAGE(STATUS "Starting CMake configuration for: libksane")
-
-# building separately or as part of kdegraphics ?
-IF(NOT KDE4_FOUND)
- FIND_PACKAGE(KDE4 REQUIRED)
-ENDIF(NOT KDE4_FOUND)
+cmake_minimum_required(VERSION 2.8.12)
+
+project(libksane)
+
+#message(STATUS "-------------------------------------------")
+#message(STATUS "Starting CMake configuration for: libksane")
+
+# ECM setup (Extended Cmake Modules)
+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)
+include(CMakePackageConfigHelpers)
+include(CheckFunctionExists)
+include(KDEInstallDirs)
+include(KDEFrameworkCompilerSettings)
+include(KDECMakeSettings)
+include(GenerateExportHeader)
+
+set(KF5_VERSION "5.0.0")
+
+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"
+)
+
+# 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)
+
+# Required Qt5 components to build this framework
+find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets)
+
+# Required KF5 frameworks
+find_package(KF5Config ${KF5_VERSION} REQUIRED)
+#find_package(KF5GuiAddons ${KF5_VERSION} REQUIRED)
+find_package(KF5I18n ${KF5_VERSION} REQUIRED)
+#find_package(KF5KIO ${KF5_VERSION} REQUIRED)
+find_package(KF5PrintUtils ${KF5_VERSION} REQUIRED)
+find_package(KF5XmlGui ${KF5_VERSION} REQUIRED)
+#find_package(KF5Notifications ${KF5_VERSION} REQUIRED)
+find_package(KF5KDE4Support ${KF5_VERSION} REQUIRED)
# 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)
-
-ADD_DEFINITIONS (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}
+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)
@@ -86,4 +129,5 @@ IF(NOT WIN32)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libksane.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
ENDIF(NOT WIN32)
-macro_display_feature_log()
+feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+
diff --git a/cmake-modules/FindSane.cmake b/cmake-modules/FindSane.cmake
new file mode 100644
index 0000000..64efa87
--- /dev/null
+++ b/cmake-modules/FindSane.cmake
@@ -0,0 +1,21 @@
+# cmake macro to test if we use sane
+#
+# SANE_FOUND - system has SANE libs
+# SANE_INCLUDE_DIR - the SANE include directory
+# SANE_LIBRARIES - The libraries needed to use SANE
+
+# Copyright (c) 2006, Marcus Hufgard <hufgardm@hufgard.de> 2006
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+FIND_PATH(SANE_INCLUDE_DIR sane/sane.h)
+
+FIND_LIBRARY(SANE_LIBRARY NAMES sane libsane
+ PATH_SUFFIXES sane
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sane DEFAULT_MSG SANE_LIBRARY SANE_INCLUDE_DIR )
+
+MARK_AS_ADVANCED(SANE_INCLUDE_DIR SANE_LIBRARY)
diff --git a/libksane/CMakeLists.txt b/libksane/CMakeLists.txt
index 9542232..f705857 100644
--- a/libksane/CMakeLists.txt
+++ b/libksane/CMakeLists.txt
@@ -1,10 +1,9 @@
-
-INCLUDE_DIRECTORIES(${SANE_INCLUDE_DIR}
+include_directories(${SANE_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/options
${CMAKE_CURRENT_SOURCE_DIR}/widgets
)
-SET(ksane_LIB_SRCS
+set(ksane_LIB_SRCS
widgets/gamma_disp.cpp
widgets/labeled_gamma.cpp
widgets/labeled_checkbox.cpp
@@ -34,37 +33,44 @@ SET(ksane_LIB_SRCS
options/ksane_opt_combo.cpp
)
-KDE4_ADD_LIBRARY(ksane SHARED ${ksane_LIB_SRCS})
+add_library(ksane SHARED ${ksane_LIB_SRCS})
-TARGET_LINK_LIBRARIES(ksane ${KDE4_KDEUI_LIBS}
- ${SANE_LIBRARY}
- )
+# TODO KDE4_KDEUI_LIBS
+target_link_libraries (ksane
+ LINK_PRIVATE
+ KF5::I18n
+ KF5::PrintUtils
+ KF5::KDE4Support
+ ${SANE_LIBRARY})
-SET_TARGET_PROPERTIES(ksane PROPERTIES VERSION ${KSANE_LIB_SO_VERSION_STRING} SOVERSION ${KSANE_LIB_SO_CUR_VERSION})
+set_target_properties(ksane PROPERTIES VERSION ${KSANE_LIB_SO_VERSION_STRING} SOVERSION ${KSANE_LIB_SO_CUR_VERSION})
-OPTION(COMPILE_VIEWER_TESTAPP "Compile a small test application for the viewer")
+option(COMPILE_VIEWER_TESTAPP "Compile a small test application for the viewer")
-IF (COMPILE_VIEWER_TESTAPP)
- message("Compile testapp")
- kde4_add_executable(viewer_test ksane_viewer.cpp ksane_viewer_test.cpp selectionitem.cpp)
- target_link_libraries(viewer_test ${KDE4_KDEUI_LIBS})
-ENDIF()
+# TODO later
+#if (COMPILE_VIEWER_TESTAPP)
+# message("Compile testapp")
+# # TODO later
+# kde4_add_executable(viewer_test ksane_viewer.cpp ksane_viewer_test.cpp selectionitem.cpp)
+# target_link_libraries(viewer_test ${KDE4_KDEUI_LIBS})
+#endif()
-INSTALL(TARGETS ksane ${INSTALL_TARGETS_DEFAULT_ARGS} )
+install(TARGETS ksane ${INSTALL_TARGETS_DEFAULT_ARGS} )
-INSTALL(FILES ksane.h
+install(FILES ksane.h
libksane_export.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION ${INCLUDE_INSTALL_DIR}/libksane COMPONENT Devel)
-KDE4_INSTALL_ICONS(${ICON_INSTALL_DIR})
+# TODO: KDE4_INSTALL_ICONS
+#KDE4_INSTALL_ICONS(${ICON_INSTALL_DIR})
-CONFIGURE_FILE(
+configure_file(
../KSaneConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake @ONLY
)
-INSTALL(
+install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/KSaneConfig.cmake
DESTINATION ${LIB_INSTALL_DIR}/cmake/KSane
)
diff --git a/libksane/ksane.h b/libksane/ksane.h
index 2a5245e..578172f 100644
--- a/libksane/ksane.h
+++ b/libksane/ksane.h
@@ -298,7 +298,6 @@ Q_SIGNALS:
void buttonPressed(const QString &optionName, const QString &optionLabel, bool pressed);
private:
-
KSaneWidgetPrivate * const d;
};
diff --git a/libksane/ksane_preview_thread.cpp b/libksane/ksane_preview_thread.cpp
index bc25444..1041555 100644
--- a/libksane/ksane_preview_thread.cpp
+++ b/libksane/ksane_preview_thread.cpp
@@ -25,8 +25,7 @@
*
* ============================================================ */
-// Local includes
-#include "ksane_preview_thread.moc"
+#include "ksane_preview_thread.h"
#include <KDebug>
#include <QMutexLocker>
diff --git a/libksane/ksane_scan_thread.cpp b/libksane/ksane_scan_thread.cpp
index acde273..bdbbd22 100644
--- a/libksane/ksane_scan_thread.cpp
+++ b/libksane/ksane_scan_thread.cpp
@@ -25,8 +25,7 @@
*
* ============================================================ */
-// Local includes
-#include "ksane_scan_thread.moc"
+#include "ksane_scan_thread.h"
#include <KDebug>
diff --git a/libksane/ksane_widget.cpp b/libksane/ksane_widget.cpp
index c49ff57..ae11e41 100644
--- a/libksane/ksane_widget.cpp
+++ b/libksane/ksane_widget.cpp
@@ -29,7 +29,6 @@
* ============================================================ */
#include "ksane.h"
-#include "ksane.moc"
#include <unistd.h>
@@ -58,6 +57,8 @@
#include "ksane_opt_slider.h"
#include "ksane_device_dialog.h"
#include "labeled_gamma.h"
+#include "kglobal.h"
+#include "kicon.h"
namespace KSaneIface
{
diff --git a/libksane/splittercollapser.cpp b/libksane/splittercollapser.cpp
index 484d817..5584572 100644
--- a/libksane/splittercollapser.cpp
+++ b/libksane/splittercollapser.cpp
@@ -19,9 +19,9 @@ Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
-
*/
-// Self
+
+#include "splittercollapser.h"
#include "splittercollapser.moc"
// Qt