Skip to content

Commit

Permalink
backend: build as a Framework for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVautherin committed Mar 2, 2018
1 parent dacc0e4 commit 45a3c2a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 30 deletions.
38 changes: 20 additions & 18 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ else()
endif()

# We need tinyxml2 for the camera definition parsing.
if(APPLE AND NOT IOS)
# We install the tinyxml2 library manually for macOS and iOS.
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Need to remove that d again.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/third_party/tinyxml2/libtinyxml2d.5.0.1.dylib
DESTINATION ${lib_path}
#RENAME libtinyxml2.dylib
)
else()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/third_party/tinyxml2/libtinyxml2.5.0.1.dylib
DESTINATION ${lib_path}
#RENAME libtinyxml2.dylib
)
endif()
if(APPLE)
if(NOT IOS)
# We install the tinyxml2 library manually for macOS and iOS.
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Need to remove that d again.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/third_party/tinyxml2/libtinyxml2d.5.0.1.dylib
DESTINATION ${lib_path}
#RENAME libtinyxml2.dylib
)
else()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/third_party/tinyxml2/libtinyxml2.5.0.1.dylib
DESTINATION ${lib_path}
#RENAME libtinyxml2.dylib
)
endif()

add_subdirectory(third_party/tinyxml2 EXCLUDE_FROM_ALL)
include_directories(SYSTEM third_party/tinyxml2)
link_directories(third_party/tinyxml2)
set(TINYXML2_LIBRARY tinyxml2)
add_subdirectory(third_party/tinyxml2 EXCLUDE_FROM_ALL)
include_directories(SYSTEM third_party/tinyxml2)
link_directories(third_party/tinyxml2)
set(TINYXML2_LIBRARY tinyxml2)
endif()
elseif(ANDROID)
# We install the tinyxml2 library manually for Android.
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down
52 changes: 40 additions & 12 deletions grpc/server/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,27 @@ foreach(COMPONENT_NAME ${COMPONENTS_LIST})
list(APPEND GRPC_COMPILED_SOURCES ${GRPC_COMPILED_SOURCE})
endforeach()

add_library(backend
set(BACKEND_SOURCES
backend_api.h
backend_api.cpp
backend.cpp
${GRPC_COMPILED_SOURCES}
${PB_COMPILED_SOURCES}
)

if(IOS)
set_property(SOURCE module.modulemap
PROPERTY MACOSX_PACKAGE_LOCATION "Modules")

list(APPEND BACKEND_SOURCES module.modulemap)
endif()

if(ANDROID OR IOS)
add_library(backend SHARED ${BACKEND_SOURCES})
else()
add_library(backend STATIC ${BACKEND_SOURCES})
endif()

target_link_libraries(backend
dronecore
dronecore_action
Expand All @@ -36,16 +51,29 @@ target_include_directories(backend
${PLUGINS_DIR}
)

add_executable(backend_bin
dronecore_server.cpp
)
if(IOS)
set_target_properties(backend PROPERTIES
FRAMEWORK TRUE
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_NAME_DIR @rpath
MACOSX_FRAMEWORK_IDENTIFIER io.dronecore.backend
VERSION 0.0.1
SOVERSION 0.0.1
PUBLIC_HEADER backend_api.h
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "DroneCore"
)
else()
add_executable(backend_bin
dronecore_server.cpp
)

target_link_libraries(backend_bin
backend
dronecore
)
target_link_libraries(backend_bin
backend
dronecore
)

target_include_directories(backend_bin
PRIVATE
${CMAKE_SOURCE_DIR}/core
)
target_include_directories(backend_bin
PRIVATE
${CMAKE_SOURCE_DIR}/core
)
endif()
6 changes: 6 additions & 0 deletions grpc/server/src/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module backend {
umbrella header "backend_api.h"

export *
module * { export * }
}

0 comments on commit 45a3c2a

Please sign in to comment.