Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/plugins/generic/omemoplugin/CMakeLists.txt
- +++ b/plugins/generic/omemoplugin/CMakeLists.txt
- @@ -36,11 +36,25 @@ endif()
- find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Network Widgets Xml Sql REQUIRED)
- find_package(OpenSSL COMPONENTS Crypto REQUIRED)
- #find_package(SignalProtocolC REQUIRED)
- -find_package(OMEMO_C REQUIRED)
- -if(WIN32)
- - find_package(PROTOBUF_C REQUIRED)
- +if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
- + string(TOLOWER ${CMAKE_TOOLCHAIN_FILE} TOOLCHAIN_FILE)
- + string(REGEX MATCH "mxe-conf" MXE_DETECTED "${TOOLCHAIN_FILE}")
- + if(MXE_DETECTED)
- + set(USE_MXE ON)
- + set(WIN32 ON)
- + endif()
- +endif()
- +if(NOT WIN32 OR (NOT USE_MXE))
- + find_package(OMEMO_C REQUIRED)
- +else()
- + #set(BUNDLED_OMEMO_C ON)
- + #find_package(PROTOBUF_C REQUIRED)
- + include(cmake/protobuf_c.cmake)
- + set(PBC_LIB ${PROTOBUF_C_LIBRARY})
- + include(cmake/omemo_c.cmake)
- endif()
- +
- include_directories(
- ${PLUGINS_ROOT_DIR}/include
- ${OPENSSL_INCLUDE_DIR}
- @@ -99,6 +113,7 @@ target_link_libraries(
- )
- if(WIN32)
- + add_dependencies(${PLUGIN} ProtobufCProject OmemoCProject)
- target_link_libraries(${PLUGIN}
- ${PROTOBUF_C_LIBRARY}
- )
- --- /dev/null
- +++ b/plugins/generic/omemoplugin/cmake/omemo_c.cmake
- +cmake_minimum_required(VERSION 3.10.0)
- +
- +set(OmemoCGitRepo "https://github.com/dino/libomemo-c.git")
- +
- +message(STATUS "OMEMO_C: using bundled")
- +set(OMEMO_C_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/omemo-c)
- +set(OMEMO_C_BUILD_DIR ${OMEMO_C_PREFIX}/build)
- +set(OMEMO_C_INCLUDE_DIR ${OMEMO_C_PREFIX}/src/OmemoCProject/src)
- +set(OMEMO_C_LIBRARY ${OMEMO_C_BUILD_DIR}/omemo-c/${CMAKE_STATIC_LIBRARY_PREFIX}omemo-c${D}${CMAKE_STATIC_LIBRARY_SUFFIX})
- +if(APPLE)
- + set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
- + set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
- + list(APPEND OMEMO_C_LIBRARY ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
- +endif()
- +
- +set(patch_command
- + ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/cmake/omemo-c.patch <SOURCE_DIR> &&
- + ${GIT_EXECUTABLE} checkout <SOURCE_DIR>/src/CMakeLists.txt &&
- + ${GIT_EXECUTABLE} apply <SOURCE_DIR>/omemo-c.patch)
- +
- +include(ExternalProject)
- +#set CMake options and transfer the environment to an external project
- +set(OMEMO_C_BUILD_OPTIONS
- + -DBUILD_SHARED_LIBS=OFF
- + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- + -DCMAKE_INSTALL_PREFIX=${OMEMO_C_PREFIX}/build
- + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
- + -DPROTOBUF_C_INCLUDE_DIR=${PROTOBUF_C_INCLUDE_DIR}
- + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
- + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
- + -DOSX_FRAMEWORK=OFF)
- +include(FindGit)
- +find_package(Git REQUIRED)
- +ExternalProject_Add(OmemoCProject
- + PREFIX ${OMEMO_C_PREFIX}
- + BINARY_DIR ${OMEMO_C_BUILD_DIR}
- + GIT_REPOSITORY "${OmemoCGitRepo}"
- + GIT_TAG omemo
- + CMAKE_ARGS ${OMEMO_C_BUILD_OPTIONS}
- + BUILD_BYPRODUCTS ${OMEMO_C_LIBRARY}
- + PATCH_COMMAND ${patch_command}
- + INSTALL_COMMAND ""
- + UPDATE_COMMAND ""
- + DEPENDS ProtobufCProject
- +)
- --- /dev/null
- +++ b/plugins/generic/omemoplugin/cmake/protobuf_c.cmake
- +cmake_minimum_required(VERSION 3.10.0)
- +
- +set(ProtobufCGitRepo "https://github.com/protobuf-c/protobuf-c.git")
- +
- +message(STATUS "PROTOBUF: using bundled")
- +set(PROTOBUF_C_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c)
- +set(PROTOBUF_C_BUILD_DIR ${PROTOBUF_C_PREFIX}/build)
- +set(PROTOBUF_C_INCLUDE_DIR ${PROTOBUF_C_PREFIX}/src/ProtobufCProject)
- +set(PROTOBUF_C_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c/src/ProtobufCProject/build-cmake)
- +set(PROTOBUF_C_LIBRARY ${PROTOBUF_C_BUILD_DIR}/protobuf-c/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf-c${D}${CMAKE_STATIC_LIBRARY_SUFFIX})
- +if(APPLE)
- + set(COREFOUNDATION_LIBRARY "-framework CoreFoundation")
- + set(COREFOUNDATION_LIBRARY_SECURITY "-framework Security")
- + list(APPEND PROTOBUF_C_LIBRARY ${COREFOUNDATION_LIBRARY} ${COREFOUNDATION_LIBRARY_SECURITY})
- +endif()
- +
- +include(ExternalProject)
- +#set CMake options and transfer the environment to an external project
- +
- +set(PROTOBUF_C_BUILD_OPTIONS
- + -DCMAKE_IGNORE_PATH="/usr/include/protobuf-c"
- + -DCMAKE_SYSTEM_IGNORE_PATH="/usr/include/protobuf-c"
- + -DBUILD_SHARED_LIBS=OFF
- + -DBUILD_PROTOC=OFF
- + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- + -DCMAKE_INSTALL_PREFIX=${PROTOBUF_C_PREFIX}/build
- + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
- + #-DPROTOBUF_C_ROOT_DIR=${PROTOBUF_C_ROOT_DIR}
- + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
- + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
- + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
- + -DOSX_FRAMEWORK=OFF
- +)
- +
- +include(FindGit)
- +find_package(Git REQUIRED)
- +ExternalProject_Add(ProtobufCProject
- + PREFIX ${PROTOBUF_C_PREFIX}
- + BINARY_DIR ${PROTOBUF_C_BUILD_DIR}
- + GIT_REPOSITORY "${ProtobufCGitRepo}"
- + CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${PROTOBUF_C_BUILD_OPTIONS} ${PROTOBUF_C_SOURCE_DIR}
- + CMAKE_ARGS ${PROTOBUF_C_BUILD_OPTIONS}
- + BUILD_BYPRODUCTS ${PROTOBUF_C_LIBRARY}
- + INSTALL_COMMAND ""
- + UPDATE_COMMAND ""
- +)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement