Skip to content

Commit

Permalink
CMake files updated. Added possibility to build psi with QtKeychain l…
Browse files Browse the repository at this point in the history
…ibrary bundled built from official github repository.
  • Loading branch information
Vitozz committed May 15, 2024
1 parent a4381cd commit 70f49df
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions Readme-cmake-ru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
JINGLE_SCTP)
(по-умолчанию -OFF)

> -DBUNDLED_KEYCHAIN=ON

компилировать библиотеку QtKeychain из официального репозитория github
Полезно для сборки под macOS (по-умолчанию -OFF)

> -DUSE_ASPELL=OFF

использовать механизм проверки орфографии Aspell (по-умолчанию -OFF)
Expand Down
4 changes: 4 additions & 0 deletions Readme-cmake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
65 changes: 65 additions & 0 deletions cmake/modules/qtkeychain-bundled.cmake
Original file line number Diff line number Diff line change
@@ -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}")
10 changes: 9 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70f49df

Please sign in to comment.