Advertisement
KukuRuzo

make omemo frankenshtein

Apr 28th, 2024
1,557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 5.11 KB | None | 0 0
  1. --- a/plugins/generic/omemoplugin/CMakeLists.txt
  2. +++ b/plugins/generic/omemoplugin/CMakeLists.txt
  3. @@ -36,11 +36,25 @@ endif()
  4.  find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Network Widgets Xml Sql REQUIRED)
  5.  find_package(OpenSSL COMPONENTS Crypto REQUIRED)
  6.  #find_package(SignalProtocolC REQUIRED)
  7. -find_package(OMEMO_C REQUIRED)
  8. -if(WIN32)
  9. -    find_package(PROTOBUF_C REQUIRED)
  10. +if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
  11. +    string(TOLOWER ${CMAKE_TOOLCHAIN_FILE} TOOLCHAIN_FILE)
  12. +    string(REGEX MATCH "mxe-conf" MXE_DETECTED "${TOOLCHAIN_FILE}")
  13. +    if(MXE_DETECTED)
  14. +        set(USE_MXE ON)
  15. +        set(WIN32 ON)
  16. +    endif()
  17. +endif()
  18. +if(NOT WIN32 OR (NOT USE_MXE))
  19. +    find_package(OMEMO_C REQUIRED)
  20. +else()
  21. +    #set(BUNDLED_OMEMO_C ON)
  22. +    #find_package(PROTOBUF_C REQUIRED)
  23. +    include(cmake/protobuf_c.cmake)
  24. +    set(PBC_LIB ${PROTOBUF_C_LIBRARY})
  25. +    include(cmake/omemo_c.cmake)
  26.  endif()
  27.  
  28. +
  29.  include_directories(
  30.      ${PLUGINS_ROOT_DIR}/include
  31.      ${OPENSSL_INCLUDE_DIR}
  32. @@ -99,6 +113,7 @@ target_link_libraries(
  33.  )
  34.  
  35.  if(WIN32)
  36. +    add_dependencies(${PLUGIN} ProtobufCProject OmemoCProject)
  37.      target_link_libraries(${PLUGIN}
  38.          ${PROTOBUF_C_LIBRARY}
  39.      )
  40. --- /dev/null
  41. +++ b/plugins/generic/omemoplugin/cmake/omemo_c.cmake
  42. +cmake_minimum_required(VERSION 3.10.0)
  43. +
  44. +set(OmemoCGitRepo "https://github.com/dino/libomemo-c.git")
  45. +
  46. +message(STATUS "OMEMO_C: using bundled")
  47. +set(OMEMO_C_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/omemo-c)
  48. +set(OMEMO_C_BUILD_DIR ${OMEMO_C_PREFIX}/build)
  49. +set(OMEMO_C_INCLUDE_DIR ${OMEMO_C_PREFIX}/src/OmemoCProject/src)
  50. +set(OMEMO_C_LIBRARY ${OMEMO_C_BUILD_DIR}/omemo-c/${CMAKE_STATIC_LIBRARY_PREFIX}omemo-c${D}${CMAKE_STATIC_LIBRARY_SUFFIX})
  51. +if(APPLE)
  52. +    set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
  53. +    set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
  54. +    list(APPEND OMEMO_C_LIBRARY ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
  55. +endif()
  56. +
  57. +set(patch_command
  58. +    ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/cmake/omemo-c.patch <SOURCE_DIR> &&
  59. +    ${GIT_EXECUTABLE} checkout <SOURCE_DIR>/src/CMakeLists.txt &&
  60. +    ${GIT_EXECUTABLE} apply <SOURCE_DIR>/omemo-c.patch)
  61. +
  62. +include(ExternalProject)
  63. +#set CMake options and transfer the environment to an external project
  64. +set(OMEMO_C_BUILD_OPTIONS
  65. +    -DBUILD_SHARED_LIBS=OFF
  66. +    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  67. +    -DCMAKE_INSTALL_PREFIX=${OMEMO_C_PREFIX}/build
  68. +    -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
  69. +    -DPROTOBUF_C_INCLUDE_DIR=${PROTOBUF_C_INCLUDE_DIR}
  70. +    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
  71. +    -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
  72. +    -DOSX_FRAMEWORK=OFF)
  73. +include(FindGit)
  74. +find_package(Git REQUIRED)
  75. +ExternalProject_Add(OmemoCProject
  76. +    PREFIX ${OMEMO_C_PREFIX}
  77. +    BINARY_DIR ${OMEMO_C_BUILD_DIR}
  78. +    GIT_REPOSITORY "${OmemoCGitRepo}"
  79. +    GIT_TAG omemo
  80. +    CMAKE_ARGS ${OMEMO_C_BUILD_OPTIONS}
  81. +    BUILD_BYPRODUCTS ${OMEMO_C_LIBRARY}
  82. +    PATCH_COMMAND ${patch_command}
  83. +    INSTALL_COMMAND ""
  84. +    UPDATE_COMMAND ""
  85. +    DEPENDS ProtobufCProject
  86. +)
  87. --- /dev/null
  88. +++ b/plugins/generic/omemoplugin/cmake/protobuf_c.cmake
  89. +cmake_minimum_required(VERSION 3.10.0)
  90. +
  91. +set(ProtobufCGitRepo "https://github.com/protobuf-c/protobuf-c.git")
  92. +
  93. +message(STATUS "PROTOBUF: using bundled")
  94. +set(PROTOBUF_C_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c)
  95. +set(PROTOBUF_C_BUILD_DIR ${PROTOBUF_C_PREFIX}/build)
  96. +set(PROTOBUF_C_INCLUDE_DIR ${PROTOBUF_C_PREFIX}/src/ProtobufCProject)
  97. +set(PROTOBUF_C_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c/src/ProtobufCProject/build-cmake)
  98. +set(PROTOBUF_C_LIBRARY ${PROTOBUF_C_BUILD_DIR}/protobuf-c/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf-c${D}${CMAKE_STATIC_LIBRARY_SUFFIX})
  99. +if(APPLE)
  100. +    set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
  101. +    set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
  102. +    list(APPEND PROTOBUF_C_LIBRARY ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
  103. +endif()
  104. +
  105. +include(ExternalProject)
  106. +#set CMake options and transfer the environment to an external project
  107. +
  108. +set(PROTOBUF_C_BUILD_OPTIONS
  109. +    -DCMAKE_IGNORE_PATH="/usr/include/protobuf-c"
  110. +    -DCMAKE_SYSTEM_IGNORE_PATH="/usr/include/protobuf-c"
  111. +    -DBUILD_SHARED_LIBS=OFF
  112. +    -DBUILD_PROTOC=OFF
  113. +    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  114. +    -DCMAKE_INSTALL_PREFIX=${PROTOBUF_C_PREFIX}/build
  115. +    -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
  116. +    #-DPROTOBUF_C_ROOT_DIR=${PROTOBUF_C_ROOT_DIR}
  117. +    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
  118. +    -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
  119. +    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  120. +    -DOSX_FRAMEWORK=OFF
  121. +)
  122. +
  123. +include(FindGit)
  124. +find_package(Git REQUIRED)
  125. +ExternalProject_Add(ProtobufCProject
  126. +    PREFIX ${PROTOBUF_C_PREFIX}
  127. +    BINARY_DIR ${PROTOBUF_C_BUILD_DIR}
  128. +    GIT_REPOSITORY "${ProtobufCGitRepo}"
  129. +    CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${PROTOBUF_C_BUILD_OPTIONS} ${PROTOBUF_C_SOURCE_DIR}
  130. +    CMAKE_ARGS ${PROTOBUF_C_BUILD_OPTIONS}
  131. +    BUILD_BYPRODUCTS ${PROTOBUF_C_LIBRARY}
  132. +    INSTALL_COMMAND ""
  133. +    UPDATE_COMMAND ""
  134. +)
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement