cmake: Use official CMake config for QCA
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 31 Jul 2018 20:18:05 +0000 (22:18 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
QCA has been shipping with a CMake config for a while, so use this
rather than providing a custom find module. Remove the custom
modules, as well as FindLibraryWithDebug.cmake which was only used
by them.

Move KeyEvent from common into core, since it's only used there.

CMakeLists.txt
cmake/FindLibraryWithDebug.cmake [deleted file]
cmake/FindQCA2-QT5.cmake [deleted file]
cmake/FindQCA2.cmake [deleted file]
src/common/CMakeLists.txt
src/core/CMakeLists.txt
src/core/keyevent.cpp [moved from src/common/keyevent.cpp with 100% similarity]
src/core/keyevent.h [moved from src/common/keyevent.h with 100% similarity]

index 93e98fe..c43ba1a 100644 (file)
@@ -345,8 +345,8 @@ if (BUILD_CORE)
         DESCRIPTION "the database support module for Qt5"
     )
 
-    find_package(QCA2-QT5)
-    set_package_properties(QCA2-QT5 PROPERTIES TYPE RECOMMENDED
+    find_package(Qca-qt5 2.0)
+    set_package_properties(Qca-qt5 PROPERTIES TYPE RECOMMENDED
         URL "https://projects.kde.org/projects/kdesupport/qca"
         DESCRIPTION "Qt Cryptographic Architecture"
         PURPOSE "Required for encryption support"
diff --git a/cmake/FindLibraryWithDebug.cmake b/cmake/FindLibraryWithDebug.cmake
deleted file mode 100644 (file)
index 58cd730..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-#  FIND_LIBRARY_WITH_DEBUG
-#  -> enhanced FIND_LIBRARY to allow the search for an
-#     optional debug library with a WIN32_DEBUG_POSTFIX similar
-#     to CMAKE_DEBUG_POSTFIX when creating a shared lib
-#     it has to be the second and third argument
-
-# Copyright (c) 2007, Christian Ehrlicher, <ch.ehrlicher@gmx.de>
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-MACRO(FIND_LIBRARY_WITH_DEBUG var_name win32_dbg_postfix_name dgb_postfix libname)
-
-  IF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
-
-     # no WIN32_DEBUG_POSTFIX -> simply pass all arguments to FIND_LIBRARY
-     FIND_LIBRARY(${var_name}
-                  ${win32_dbg_postfix_name}
-                  ${dgb_postfix}
-                  ${libname}
-                  ${ARGN}
-     )
-
-  ELSE(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
-
-    IF(NOT WIN32)
-      # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
-
-      FIND_LIBRARY(${var_name} ${libname} ${ARGN})
-
-    ELSE(NOT WIN32)
-
-      # 1. get all possible libnames
-      SET(args ${ARGN})
-      SET(newargs "")
-      SET(libnames_release "")
-      SET(libnames_debug "")
-
-      LIST(LENGTH args listCount)
-
-      IF("${libname}" STREQUAL "NAMES")
-        SET(append_rest 0)
-        LIST(APPEND args " ")
-
-        FOREACH(i RANGE ${listCount})
-          LIST(GET args ${i} val)
-
-          IF(append_rest)
-            LIST(APPEND newargs ${val})
-          ELSE(append_rest)
-            IF("${val}" STREQUAL "PATHS")
-              LIST(APPEND newargs ${val})
-              SET(append_rest 1)
-            ELSE("${val}" STREQUAL "PATHS")
-              LIST(APPEND libnames_release "${val}")
-              LIST(APPEND libnames_debug   "${val}${dgb_postfix}")
-            ENDIF("${val}" STREQUAL "PATHS")
-          ENDIF(append_rest)
-
-        ENDFOREACH(i)
-
-      ELSE("${libname}" STREQUAL "NAMES")
-
-        # just one name
-        LIST(APPEND libnames_release "${libname}")
-        LIST(APPEND libnames_debug   "${libname}${dgb_postfix}")
-
-        SET(newargs ${args})
-
-      ENDIF("${libname}" STREQUAL "NAMES")
-
-      # search the release lib
-      FIND_LIBRARY(${var_name}_RELEASE
-                   NAMES ${libnames_release}
-                   ${newargs}
-      )
-
-      # search the debug lib
-      FIND_LIBRARY(${var_name}_DEBUG
-                   NAMES ${libnames_debug}
-                   ${newargs}
-      )
-
-      IF(${var_name}_RELEASE AND ${var_name}_DEBUG)
-
-        # both libs found
-        SET(${var_name} optimized ${${var_name}_RELEASE}
-                        debug     ${${var_name}_DEBUG})
-
-      ELSE(${var_name}_RELEASE AND ${var_name}_DEBUG)
-
-        IF(${var_name}_RELEASE)
-
-          # only release found
-          SET(${var_name} ${${var_name}_RELEASE})
-
-        ELSE(${var_name}_RELEASE)
-
-          # only debug (or nothing) found
-          SET(${var_name} ${${var_name}_DEBUG})
-
-        ENDIF(${var_name}_RELEASE)
-       
-      ENDIF(${var_name}_RELEASE AND ${var_name}_DEBUG)
-
-      MARK_AS_ADVANCED(${var_name}_RELEASE)
-      MARK_AS_ADVANCED(${var_name}_DEBUG)
-
-    ENDIF(NOT WIN32)
-
-  ENDIF(NOT "${win32_dbg_postfix_name}" STREQUAL "WIN32_DEBUG_POSTFIX")
-
-ENDMACRO(FIND_LIBRARY_WITH_DEBUG)
diff --git a/cmake/FindQCA2-QT5.cmake b/cmake/FindQCA2-QT5.cmake
deleted file mode 100644 (file)
index 6b1e0a9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-# - Try to find QCA2 (Qt Cryptography Architecture 2) for QT5
-# Once done this will define
-#
-#  QCA2-QT5_FOUND - system has QCA2-QT5
-#  QCA2-QT5_INCLUDE_DIR - the QCA2-QT5 include directory
-#  QCA2-QT5_LIBRARIES - the libraries needed to use QCA2-QT5
-#  QCA2-QT5_DEFINITIONS - Compiler switches required for using QCA2-QT5
-#
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-
-# Copyright (c) 2006, Michael Larouche, <michael.larouche@kdemail.net>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-include(FindPackageHandleStandardArgs)
-
-find_package(Qca-qt5 QUIET)
-if(Qca-qt5_FOUND)
-
-  set(QCA2-QT5_INCLUDE_DIR ${CMAKE_PREFIX_PATH}/include)#just to have any value as the real include dir is imported by linking to qca-qt5
-  set(QCA2-QT5_LIBRARIES qca-qt5)
-
-  find_package_handle_standard_args(QCA2-QT5 DEFAULT_MSG QCA2-QT5_LIBRARIES QCA2-QT5_INCLUDE_DIR)
-
-  mark_as_advanced(QCA2-QT5_INCLUDE_DIR QCA2-QT5_LIBRARIES)
-else()
-
-include(FindLibraryWithDebug)
-
-if (QCA2-QT5_INCLUDE_DIR AND QCA2-QT5_LIBRARIES)
-
-  # in cache already
-  set(QCA2-QT5_FOUND TRUE)
-
-else()
-
-
-  if (NOT WIN32)
-    find_package(PkgConfig)
-    pkg_check_modules(PC_QCA2-QT5 QUIET qca2-qt5)
-    set(QCA2-QT5_DEFINITIONS ${PC_QCA2-QT5_CFLAGS_OTHER})
-  endif()
-
-  find_library_with_debug(QCA2-QT5_LIBRARIES
-                  WIN32_DEBUG_POSTFIX d
-                  NAMES qca-qt5
-                  HINTS ${PC_QCA2-QT5_LIBDIR} ${PC_QCA2-QT5_LIBRARY_DIRS}
-                  )
-
-  find_path(QCA2-QT5_INCLUDE_DIR QtCrypto
-            HINTS ${PC_QCA2-QT5_INCLUDEDIR} ${PC_QCA2-QT5_INCLUDE_DIRS}
-            PATH_SUFFIXES QtCrypto)
-
-  find_package_handle_standard_args(QCA2-QT5 DEFAULT_MSG QCA2-QT5_LIBRARIES QCA2-QT5_INCLUDE_DIR)
-
-  mark_as_advanced(QCA2-QT5_INCLUDE_DIR QCA2-QT5_LIBRARIES)
-
-endif()
-endif()
diff --git a/cmake/FindQCA2.cmake b/cmake/FindQCA2.cmake
deleted file mode 100644 (file)
index 182a22f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-# - Try to find QCA2 (Qt Cryptography Architecture 2)
-# Once done this will define
-#
-#  QCA2_FOUND - system has QCA2
-#  QCA2_INCLUDE_DIR - the QCA2 include directory
-#  QCA2_LIBRARIES - the libraries needed to use QCA2
-#  QCA2_DEFINITIONS - Compiler switches required for using QCA2
-#
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-
-# Copyright (c) 2006, Michael Larouche, <michael.larouche@kdemail.net>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-include(FindLibraryWithDebug)
-
-if (QCA2_INCLUDE_DIR AND QCA2_LIBRARIES)
-
-  # in cache already
-  set(QCA2_FOUND TRUE)
-
-else()
-
-
-  if (NOT WIN32)
-    find_package(PkgConfig)
-    pkg_check_modules(PC_QCA2 QUIET qca2)
-    set(QCA2_DEFINITIONS ${PC_QCA2_CFLAGS_OTHER})
-  endif()
-
-  find_library_with_debug(QCA2_LIBRARIES
-                  WIN32_DEBUG_POSTFIX d
-                  NAMES qca
-                  HINTS ${PC_QCA2_LIBDIR} ${PC_QCA2_LIBRARY_DIRS}
-                  )
-
-  find_path(QCA2_INCLUDE_DIR QtCrypto
-            HINTS ${PC_QCA2_INCLUDEDIR} ${PC_QCA2_INCLUDE_DIRS}
-            PATH_SUFFIXES QtCrypto)
-
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(QCA2  DEFAULT_MSG  QCA2_LIBRARIES QCA2_INCLUDE_DIR)
-
-  mark_as_advanced(QCA2_INCLUDE_DIR QCA2_LIBRARIES)
-
-endif()
index caace32..1b77daf 100644 (file)
@@ -58,10 +58,6 @@ set(SOURCES
     protocol.h
 )
 
-if (QCA2-QT5_FOUND)
-    set(SOURCES ${SOURCES} keyevent.cpp)
-endif()
-
 if (HAVE_SYSLOG)
     add_definitions(-DHAVE_SYSLOG)
 endif()
index db3337e..634af92 100644 (file)
@@ -51,13 +51,6 @@ if(HAVE_SSL)
   include_directories(${OPENSSL_INCLUDE_DIR})
 endif()
 
-if (QCA2-QT5_FOUND)
-    add_definitions(-DHAVE_QCA2)
-    include_directories(${QCA2-QT5_INCLUDE_DIR})
-    list(APPEND SOURCES cipher.cpp)
-    list(APPEND LIBS ${QCA2-QT5_LIBRARIES})
-endif()
-
 # Build with LDAP if told to do so.
 if(HAVE_LDAP)
     include_directories(${LDAP_INCLUDE_DIR})
@@ -75,6 +68,12 @@ qt5_use_modules(mod_core Core Network Script Sql)
 
 target_link_libraries(mod_core mod_common ${LIBS})
 
+if (Qca-qt5_FOUND)
+    target_sources(mod_core PRIVATE cipher.cpp keyevent.cpp)
+    target_link_libraries(mod_core qca-qt5)
+    target_compile_definitions(mod_core PUBLIC -DHAVE_QCA2)
+endif()
+
 if(HAVE_LDAP)
     target_link_libraries(mod_core ${LDAP_LIBRARIES})
 endif(HAVE_LDAP)
similarity index 100%
rename from src/common/keyevent.h
rename to src/core/keyevent.h