Skip to content

[CHORE]: prepare files to compile native libraries using conan. #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 14 additions & 100 deletions privmx-endpoint/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,97 +1,12 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.

# Sets the minimum CMake version required for this project.
cmake_minimum_required(VERSION 3.22.1)

# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
# Since this is the top level CMakeLists.txt, the project name is also accessible
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
# build script scope).
cmake_minimum_required(VERSION 3.15)
project("privmx-endpoint-java")
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")

if( NOT DEFINED CMAKE_DESTINATION_OS )
set(CMAKE_DESTINATION_OS ${CMAKE_SYSTEM_NAME})
if ("${JAVA_HOME}" STREQUAL "")
SET(JAVA_HOME "$ENV{JAVA_HOME}")
endif ()

if( NOT DEFINED CMAKE_DESTINATION_ARCHITECTURE)
if(CMAKE_DESTINATION_OS STREQUAL "Android" AND DEFINED CMAKE_ANDROID_ARCH_ABI)
set(CMAKE_DESTINATION_ARCHITECTURE ${CMAKE_ANDROID_ARCH_ABI})
else()
set(CMAKE_DESTINATION_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
endif ()
endif()

if("${CMAKE_DESTINATION_OS}" STREQUAL "Darwin")
set(file_extension "dylib")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_INSTALL_RPATH "@loader_path")
elseif ("${CMAKE_DESTINATION_OS}" STREQUAL "Windows")
set(file_extension "dll")
else ()
set(file_extension "so")
endif ()

message(DEBUG "CMAKE DEST OS ${CMAKE_DESTINATION_OS}")
message(DEBUG "CMAKE DEST PROCESSOR ${CMAKE_DESTINATION_ARCHITECTURE}")

add_library(ssl SHARED IMPORTED GLOBAL)
set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libssl.${file_extension})

add_library(crypto SHARED IMPORTED GLOBAL)
set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libcrypto.${file_extension})

add_library(gmp SHARED IMPORTED GLOBAL)
set_target_properties(gmp PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libgmp.${file_extension})

add_library(PocoFoundation SHARED IMPORTED GLOBAL)
set_target_properties(PocoFoundation PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoFoundation.${file_extension})

add_library(PocoJSON SHARED IMPORTED GLOBAL)
set_target_properties(PocoJSON PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoJSON.${file_extension})

add_library(PocoNet SHARED IMPORTED GLOBAL)
set_target_properties(PocoNet PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoNet.${file_extension})

add_library(PocoCrypto SHARED IMPORTED GLOBAL)
set_target_properties(PocoCrypto PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoCrypto.${file_extension})

add_library(PocoXML SHARED IMPORTED GLOBAL)
set_target_properties(PocoXML PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoXML.${file_extension})

add_library(PocoNetSSL SHARED IMPORTED GLOBAL)
set_target_properties(PocoNetSSL PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoNetSSL.${file_extension})

add_library(PocoUtil SHARED IMPORTED GLOBAL)
set_target_properties(PocoUtil PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPocoUtil.${file_extension})

add_library(Pson SHARED IMPORTED GLOBAL)
set_target_properties(Pson PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libPson.${file_extension})

add_library(libprivmx SHARED IMPORTED GLOBAL)
set_target_properties(libprivmx PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmx.${file_extension})

add_library(privmxendpointcore SHARED IMPORTED GLOBAL)
set_target_properties(privmxendpointcore PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmxendpointcore.${file_extension})

add_library(privmxendpointcrypto SHARED IMPORTED GLOBAL)
set_target_properties(privmxendpointcrypto PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmxendpointcrypto.${file_extension})

add_library(privmxendpointstore SHARED IMPORTED GLOBAL)
set_target_properties(privmxendpointstore PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmxendpointstore.${file_extension})

add_library(privmxendpointthread SHARED IMPORTED GLOBAL)
set_target_properties(privmxendpointthread PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmxendpointthread.${file_extension})

add_library(privmxendpointinbox SHARED IMPORTED GLOBAL)
set_target_properties(privmxendpointinbox PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_DESTINATION_OS}/${CMAKE_DESTINATION_ARCHITECTURE}/lib/libprivmxendpointinbox.${file_extension})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/include ${JAVA_HOME}/include ${JAVA_HOME}/include/darwin)

find_package(privmxendpoint REQUIRED)
add_library(${CMAKE_PROJECT_NAME} SHARED
${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp
Expand All @@ -106,13 +21,12 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
${CMAKE_CURRENT_SOURCE_DIR}/modules/BackendRequester.cpp
)

# Android Debugging
#find_library( log-lib log )
#target_link_libraries(${CMAKE_PROJECT_NAME} ${log-lib} ${log})
target_link_libraries(${CMAKE_PROJECT_NAME} ssl crypto)
target_link_libraries(${CMAKE_PROJECT_NAME} gmp)
target_link_libraries(${CMAKE_PROJECT_NAME} PocoFoundation PocoXML PocoJSON PocoNet PocoNetSSL PocoUtil PocoCrypto)
target_link_libraries(${CMAKE_PROJECT_NAME} Pson libprivmx privmxendpointcore privmxendpointcrypto privmxendpointstore privmxendpointthread privmxendpointinbox)
message(DEBUG "Install to ${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(IMPORTED_RUNTIME_ARTIFACTS crypto ssl gmp PocoFoundation PocoXML PocoJSON PocoNet PocoNetSSL PocoUtil PocoCrypto Pson libprivmx privmxendpointcore privmxendpointcrypto privmxendpointstore privmxendpointthread privmxendpointinbox DESTINATION ${CMAKE_INSTALL_PREFIX})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/include ${JAVA_HOME}/include ${JAVA_HOME}/include/linux ${JAVA_HOME}/include/darwin)

target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
privmxendpoint::privmxendpointcore
privmxendpoint::privmxendpointstore
privmxendpoint::privmxendpointinbox
privmxendpoint::privmxendpointthread
privmxendpoint::privmxendpointcrypto
)
9 changes: 9 additions & 0 deletions privmx-endpoint/src/main/cpp/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[requires]
privmx-endpoint/2.2.4

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout
3 changes: 1 addition & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ dependencyResolutionManagement {
}
}

rootProject.name = "PrivmxEndpoint"
rootProject.name = "PrivmxEndpointJava"
include ':privmx-endpoint'
include ':privmx-endpoint-extra'
include ':privmx-endpoint-android'
include ':privmx-endpoint-jni'
include ':examples:privmx-snippets'
project(':privmx-endpoint-jni').projectDir = file("privmx-endpoint/src/main/cpp")