This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CMake support for building the support-lib
Adds the target "djinni" with the options DJINNI_WITH_OBJC, DJINNI_WITH_JNI and DJINNI_FRAMEWORK.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) | ||
|
||
project(Djinni) | ||
|
||
include(GNUInstallDirs) | ||
|
||
add_library(djinni SHARED | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/djinni_common.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/proxy_cache_interface.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/support-lib/proxy_cache_impl.hpp" | ||
) | ||
target_include_directories(djinni | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
) | ||
set_target_properties(djinni PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED ON | ||
CXX_EXTENSIONS OFF | ||
) | ||
|
||
# OBJC support | ||
option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni." OFF) | ||
if(DJINNI_WITH_OBJC) | ||
target_sources(djinni | ||
PUBLIC | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/objc/DJICppWrapperCache+Private.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/objc/DJIError.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/objc/DJIMarshal+Private.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/objc/DJIObjcWrapperCache+Private.h" | ||
PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/support-lib/objc/DJIError.mm" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/support-lib/objc/DJIProxyCaches.mm" | ||
) | ||
target_compile_options(djinni PUBLIC "-fobjc-arc") | ||
endif() | ||
|
||
# JNI SUPPROT | ||
option(DJINNI_WITH_JNI "Include the JNI support code in Djinni." OFF) | ||
if(DJINNI_WITH_JNI) | ||
target_sources(djinni | ||
PUBLIC | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/jni/djinni_support.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/include/djinni/support-lib/jni/Marshal.hpp" | ||
PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/support-lib/jni/djinni_main.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/support-lib/jni/djinni_support.cpp" | ||
) | ||
# Do not use the host's jni.h on Android as it is provided automatically by the NDK | ||
if(NOT ANDROID) | ||
find_package(JNI REQUIRED QUIET) | ||
target_include_directories(djinni | ||
PUBLIC | ||
${JNI_INCLUDE_DIRS} | ||
) | ||
endif() | ||
endif() | ||
|
||
if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI)) | ||
message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI must be enabled.") | ||
endif() | ||
|
||
add_library(dropbox::djinni ALIAS djinni) | ||
|
||
# INSTALLATION | ||
install(TARGETS djinni | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
install(DIRECTORY include/djinni DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
# AS APPLE FRAMEWORK | ||
option(DJINNI_FRAMEWORK "If enabled the Objective-C binary of Djinni is built as djinni.framework otherwise as djinni.dylib on Apple systems." OFF) | ||
if(APPLE AND DJINNI_FRAMEWORK) | ||
set_target_properties(djinni PROPERTIES | ||
FRAMEWORK ON | ||
MACOSX_FRAMEWORK_IDENTIFIER com.dropbox.djinni | ||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" | ||
OUTPUT_NAME djinni | ||
) | ||
install(DIRECTORY include/djinni/ DESTINATION ${CMAKE_INSTALL_LIBDIR}/djinni.framework/Header) | ||
endif() |