From 8b07343ab53d37b5340a56bde2d71ff2a3afb14a Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 31 Jul 2018 22:18:05 +0200 Subject: [PATCH] cmake: Use official CMake config for QCA 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 | 4 +- cmake/FindLibraryWithDebug.cmake | 113 ------------------------------ cmake/FindQCA2-QT5.cmake | 61 ---------------- cmake/FindQCA2.cmake | 48 ------------- src/common/CMakeLists.txt | 4 -- src/core/CMakeLists.txt | 13 ++-- src/{common => core}/keyevent.cpp | 0 src/{common => core}/keyevent.h | 0 8 files changed, 8 insertions(+), 235 deletions(-) delete mode 100644 cmake/FindLibraryWithDebug.cmake delete mode 100644 cmake/FindQCA2-QT5.cmake delete mode 100644 cmake/FindQCA2.cmake rename src/{common => core}/keyevent.cpp (100%) rename src/{common => core}/keyevent.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93e98fe8..c43ba1ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 58cd7308..00000000 --- a/cmake/FindLibraryWithDebug.cmake +++ /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, -# 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 index 6b1e0a99..00000000 --- a/cmake/FindQCA2-QT5.cmake +++ /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, -# -# 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 index 182a22f7..00000000 --- a/cmake/FindQCA2.cmake +++ /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, -# -# 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() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index caace32b..1b77dafb 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -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() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index db3337ee..634af922 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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) diff --git a/src/common/keyevent.cpp b/src/core/keyevent.cpp similarity index 100% rename from src/common/keyevent.cpp rename to src/core/keyevent.cpp diff --git a/src/common/keyevent.h b/src/core/keyevent.h similarity index 100% rename from src/common/keyevent.h rename to src/core/keyevent.h -- 2.20.1