diff --git a/CMakeLists.txt b/CMakeLists.txt index 92f0d30e4..8e07be180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,8 @@ option( BUNDLED_IRIS_ALL "Build bundled iris library with bundled QCA and bundle # note Blake2b is needed only with Qt5. Qt6 has its own implementation option( IRIS_BUNDLED_QCA "Adds: DTLS, Blake2b (needed with Qt5) and other useful for XMPP crypto-stuff" ${DEFAULT_BUNDLED_QCA} ) option( IRIS_BUNDLED_USRSCTP "Compile compatible usrsctp lib when system one is not available or uncompatible (required for p2p file transfer)" ${DEFAULT_BUNDLED_USRSCTP} ) +option( BUNDLED_KEYCHAIN "Build QtKeychain library bundled" OFF ) + if (UNIX AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") option( ENABLE_ASAN "Enable compilation with address sanitizer" OFF ) endif() diff --git a/Readme-cmake-ru.txt b/Readme-cmake-ru.txt index dedbd76ef..b95df6567 100644 --- a/Readme-cmake-ru.txt +++ b/Readme-cmake-ru.txt @@ -77,6 +77,11 @@ JINGLE_SCTP) (по-умолчанию -OFF) +> -DBUNDLED_KEYCHAIN=ON + + компилировать библиотеку QtKeychain из официального репозитория github + Полезно для сборки под macOS (по-умолчанию -OFF) + > -DUSE_ASPELL=OFF использовать механизм проверки орфографии Aspell (по-умолчанию -OFF) diff --git a/Readme-cmake.txt b/Readme-cmake.txt index 371173b3d..a038c4613 100644 --- a/Readme-cmake.txt +++ b/Readme-cmake.txt @@ -80,6 +80,10 @@ or uncompatible (required for p2p file transfer. Available only if JINGLE_SCTP flag set to ON) +> -DBUNDLED_KEYCHAIN=ON + + to build QtKeychain library bundled (useful for macOS) (default OFF) + > -DUSE_ASPELL=OFF to use Aspell spellchecker (default OFF) diff --git a/cmake/modules/qtkeychain-bundled.cmake b/cmake/modules/qtkeychain-bundled.cmake new file mode 100644 index 000000000..8261c9d86 --- /dev/null +++ b/cmake/modules/qtkeychain-bundled.cmake @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.10.0) + +set(QtkeychainRepo "https://github.com/frankosterfeld/qtkeychain.git") + +set(libname qt${QT_DEFAULT_MAJOR_VERSION}keychain) +message(STATUS "Qt${QT_DEFAULT_MAJOR_VERSION}Keychain: using bundled") +set(Qtkeychain_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${libname}) +set(Qtkeychain_BUILD_DIR ${Qtkeychain_PREFIX}/build) +set(Qtkeychain_INSTALL_DIR ${Qtkeychain_PREFIX}/install) +set(Qtkeychain_INCLUDE_DIR ${Qtkeychain_INSTALL_DIR}/include) +set(Qtkeychain_LIBRARY_NAME +${CMAKE_STATIC_LIBRARY_PREFIX}${libname}${CMAKE_STATIC_LIBRARY_SUFFIX} +) +set(Qtkeychain_LIBRARY ${Qtkeychain_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${Qtkeychain_LIBRARY_NAME}) + +if(APPLE) + set(COREFOUNDATION_LIBRARY "-framework CoreFoundation") + set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security") + list(APPEND Qtkeychain_LIBRARY ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY}) +endif() + +if(${QT_DEFAULT_MAJOR_VERSION} VERSION_GREATER "5") + set(BUILD_WITH_QT6 ON) +else() + set(BUILD_WITH_QT6 OFF) +endif() + +include(FindGit) +find_package(Git REQUIRED) + +include(FindPkgConfig) + +include(ExternalProject) +#set CMake options and transfer the environment to an external project +set(Qtkeychain_BUILD_OPTIONS + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${Qtkeychain_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DBUILD_TEST_APPLICATION=OFF + -DBUILD_WITH_QT6=${BUILD_WITH_QT6} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DLIBSECRET_SUPPORT=OFF + -DOSX_FRAMEWORK=OFF +) + +ExternalProject_Add(QtkeychainProject + PREFIX ${Qtkeychain_PREFIX} + BINARY_DIR ${Qtkeychain_BUILD_DIR} + GIT_REPOSITORY "${QtkeychainRepo}" + GIT_TAG main + CMAKE_ARGS ${Qtkeychain_BUILD_OPTIONS} + BUILD_BYPRODUCTS ${Qtkeychain_LIBRARY} + UPDATE_COMMAND "" +) + +set(QTKEYCHAIN_LIBRARIES ${Qtkeychain_LIBRARY}) +set(QTKEYCHAIN_INCLUDE_DIRS ${Qtkeychain_INCLUDE_DIR}) + +message(STATUS "LIB=${Qtkeychain_LIBRARY}") +message(STATUS "HEADER=${Qtkeychain_INCLUDE_DIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f644748c..a5dd07d45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,7 +81,11 @@ else() find_package(Qt${QT_DEFAULT_MAJOR_VERSION} 6.6 REQUIRED COMPONENTS ${REQUIRED_QT_COMPONENTS}) endif() if(USE_KEYCHAIN) - find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED COMPONENTS Keychain) + if(NOT BUNDLED_KEYCHAIN) + find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED COMPONENTS Keychain) + else() + include(qtkeychain-bundled) + endif() set(KEYCHAIN_LIBS ${QTKEYCHAIN_LIBRARIES}) include_directories(${QTKEYCHAIN_INCLUDE_DIRS}) add_definitions(-DHAVE_KEYCHAIN) @@ -433,6 +437,10 @@ if(UNIX OR IS_WEBENGINE) endif() add_dependencies(${PROJECT_NAME} build_ui_files) +if(BUNDLED_KEYCHAIN) + add_dependencies(${PROJECT_NAME} QtkeychainProject) +endif() + #Add win32 additional dependencies if(WIN32 AND MSVC) list(APPEND EXTRA_LIBS