From cfd02731beb3f836eb3d3e8bbc850b61883ba69d Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@gmail.com> Date: Thu, 16 Mar 2017 10:00:45 +0000 Subject: [PATCH 1/3] add CMake support to djinni --- support-lib/CMakeLists.txt | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 support-lib/CMakeLists.txt diff --git a/support-lib/CMakeLists.txt b/support-lib/CMakeLists.txt new file mode 100644 index 000000000..5ea4a3526 --- /dev/null +++ b/support-lib/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.6.0) + +project(Djinni) + +include(GNUInstallDirs) + +set(SRC_SHARED + "djinni_common.hpp" + "proxy_cache_interface.hpp" + "proxy_cache_impl.hpp" +) + +set(SRC_JNI + "jni/djinni_support.hpp" + "jni/Marshal.hpp" + "jni/djinni_support.cpp" +) + +set(SRC_OBJC + "objc/DJICppWrapperCache+Private.h" + "objc/DJIError.h" + "objc/DJIMarshal+Private.h" + "objc/DJIObjcWrapperCache+Private.h" + "objc/DJIError.mm" + "objc/DJIProxyCaches.mm" +) + +option(DJINNI_STATIC_LIB "Build Djinni as a static library instead of dynamic (the default)." off) +if(DJINNI_STATIC_LIB) + add_library(djinni STATIC ${SRC_SHARED}) +else() + add_library(djinni SHARED ${SRC_SHARED}) +endif() +source_group("" FILES ${SRC_SHARED}) + +set_target_properties(djinni PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED true + CXX_EXTENSIONS false +) + +# Objective-C support +option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni." off) +if(DJINNI_WITH_OBJC) + target_include_directories(djinni PUBLIC "$") + target_sources(djinni PRIVATE ${SRC_OBJC}) + source_group("objc" FILES ${SRC_OBJC}) + target_compile_options(djinni PUBLIC "-fobjc-arc") +endif() + +# JNI support +option(DJINNI_WITH_JNI "Include the JNI support code in Djinni." off) +if(DJINNI_WITH_JNI) + if(NOT DJINNI_STATIC_LIB) + list(APPEND SRC_JNI "jni/djinni_main.cpp") + endif() + target_include_directories(djinni PUBLIC "$") + target_sources(djinni PRIVATE ${SRC_JNI}) + source_group("jni" FILES ${SRC_JNI}) + # 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() + # Exceptions and RTTI are disabled in the NDK by default + if(ANDROID) + target_compile_options(djinni PRIVATE "-fexceptions" "-frtti") + 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() + +# Store path to the "run" executable so it can be passed as argument to add_custom_command() scripts +set(DJINNI_RUN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/run" CACHE FILEPATH "Path to the Djinni generator executable.") From 568b08b0ba1133b30ea09495cb9b9795b12a8c58 Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@users.noreply.github.com> Date: Fri, 31 Mar 2017 16:57:07 +0100 Subject: [PATCH 2/3] Apply target_compile_options to all targets --- support-lib/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/support-lib/CMakeLists.txt b/support-lib/CMakeLists.txt index 5ea4a3526..1ef23d48f 100644 --- a/support-lib/CMakeLists.txt +++ b/support-lib/CMakeLists.txt @@ -62,12 +62,10 @@ if(DJINNI_WITH_JNI) find_package(JNI REQUIRED QUIET) target_include_directories(djinni PUBLIC "${JNI_INCLUDE_DIRS}") endif() - # Exceptions and RTTI are disabled in the NDK by default - if(ANDROID) - target_compile_options(djinni PRIVATE "-fexceptions" "-frtti") - endif() endif() +target_compile_options(djinni PRIVATE "-fexceptions" "-frtti") + 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() From 8528ff9085f76dc0a9cd9779b44dca127b3906b9 Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@gmail.com> Date: Tue, 4 Apr 2017 18:14:47 +0100 Subject: [PATCH 3/3] move CMakeLists.txt file to root directory and rename target name to djinni_support_lib --- CMakeLists.txt | 72 +++++++++++++++++++++++++++++++++++++ support-lib/CMakeLists.txt | 74 -------------------------------------- 2 files changed, 72 insertions(+), 74 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 support-lib/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..90564bae0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 3.6.0) + +project(djinni_support_lib) + +include(GNUInstallDirs) + +set(SRC_SHARED + "support-lib/djinni_common.hpp" + "support-lib/proxy_cache_interface.hpp" + "support-lib/proxy_cache_impl.hpp" +) + +set(SRC_JNI + "support-lib/jni/djinni_support.hpp" + "support-lib/jni/Marshal.hpp" + "support-lib/jni/djinni_support.cpp" +) + +set(SRC_OBJC + "support-lib/objc/DJICppWrapperCache+Private.h" + "support-lib/objc/DJIError.h" + "support-lib/objc/DJIMarshal+Private.h" + "support-lib/objc/DJIObjcWrapperCache+Private.h" + "support-lib/objc/DJIError.mm" + "support-lib/objc/DJIProxyCaches.mm" +) + +option(DJINNI_STATIC_LIB "Build Djinni support library as a static library instead of dynamic (the default)." off) +if(DJINNI_STATIC_LIB) + add_library(djinni_support_lib STATIC ${SRC_SHARED}) +else() + add_library(djinni_support_lib SHARED ${SRC_SHARED}) +endif() +source_group("" FILES ${SRC_SHARED}) + +set_target_properties(djinni_support_lib PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED true + CXX_EXTENSIONS false +) + +# Objective-C support +option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni support library." off) +if(DJINNI_WITH_OBJC) + target_include_directories(djinni_support_lib PUBLIC "$") + target_sources(djinni_support_lib PRIVATE ${SRC_OBJC}) + source_group("objc" FILES ${SRC_OBJC}) + target_compile_options(djinni_support_lib PUBLIC "-fobjc-arc") +endif() + +# JNI support +option(DJINNI_WITH_JNI "Include the JNI support code in Djinni support library." off) +if(DJINNI_WITH_JNI) + if(NOT DJINNI_STATIC_LIB) + list(APPEND SRC_JNI "support-lib/jni/djinni_main.cpp") + endif() + target_include_directories(djinni_support_lib PUBLIC "$") + target_sources(djinni_support_lib PRIVATE ${SRC_JNI}) + source_group("jni" FILES ${SRC_JNI}) + # 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_support_lib 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() + +# Store path to the "run" executable so it can be passed as argument to add_custom_command() scripts +set(DJINNI_RUN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/run" CACHE FILEPATH "Path to the Djinni generator executable.") diff --git a/support-lib/CMakeLists.txt b/support-lib/CMakeLists.txt deleted file mode 100644 index 1ef23d48f..000000000 --- a/support-lib/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -cmake_minimum_required(VERSION 3.6.0) - -project(Djinni) - -include(GNUInstallDirs) - -set(SRC_SHARED - "djinni_common.hpp" - "proxy_cache_interface.hpp" - "proxy_cache_impl.hpp" -) - -set(SRC_JNI - "jni/djinni_support.hpp" - "jni/Marshal.hpp" - "jni/djinni_support.cpp" -) - -set(SRC_OBJC - "objc/DJICppWrapperCache+Private.h" - "objc/DJIError.h" - "objc/DJIMarshal+Private.h" - "objc/DJIObjcWrapperCache+Private.h" - "objc/DJIError.mm" - "objc/DJIProxyCaches.mm" -) - -option(DJINNI_STATIC_LIB "Build Djinni as a static library instead of dynamic (the default)." off) -if(DJINNI_STATIC_LIB) - add_library(djinni STATIC ${SRC_SHARED}) -else() - add_library(djinni SHARED ${SRC_SHARED}) -endif() -source_group("" FILES ${SRC_SHARED}) - -set_target_properties(djinni PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED true - CXX_EXTENSIONS false -) - -# Objective-C support -option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni." off) -if(DJINNI_WITH_OBJC) - target_include_directories(djinni PUBLIC "$") - target_sources(djinni PRIVATE ${SRC_OBJC}) - source_group("objc" FILES ${SRC_OBJC}) - target_compile_options(djinni PUBLIC "-fobjc-arc") -endif() - -# JNI support -option(DJINNI_WITH_JNI "Include the JNI support code in Djinni." off) -if(DJINNI_WITH_JNI) - if(NOT DJINNI_STATIC_LIB) - list(APPEND SRC_JNI "jni/djinni_main.cpp") - endif() - target_include_directories(djinni PUBLIC "$") - target_sources(djinni PRIVATE ${SRC_JNI}) - source_group("jni" FILES ${SRC_JNI}) - # 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() - -target_compile_options(djinni PRIVATE "-fexceptions" "-frtti") - -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() - -# Store path to the "run" executable so it can be passed as argument to add_custom_command() scripts -set(DJINNI_RUN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/run" CACHE FILEPATH "Path to the Djinni generator executable.")