Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 20 | file(GLOB java_sources src/**/*.java) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 21 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 22 | if(ANDROID) |
| 23 | set(android_sources |
| 24 | android/build.gradle |
| 25 | android/settings.gradle |
| 26 | android/src/main/AndroidManifest.xml |
| 27 | ) |
| 28 | set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar) |
| 29 | add_custom_command( |
| 30 | OUTPUT ${THRIFT_AAR} |
| 31 | COMMAND ${GRADLE_EXECUTABLE} -p${CMAKE_CURRENT_SOURCE_DIR}/android -PbuildDir=${CMAKE_CURRENT_BINARY_DIR} assemble |
| 32 | DEPENDS ${java_sources} ${android_sources}) |
| 33 | add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 34 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 35 | else(ANDROID) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 36 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 37 | if(IS_ABSOLUTE "${LIB_INSTALL_DIR}") |
| 38 | set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java") |
| 39 | else() |
| 40 | set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java") |
| 41 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 42 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 43 | if(IS_ABSOLUTE "${DOC_INSTALL_DIR}") |
| 44 | set(JAVA_DOC_INSTALL_DIR "${DOC_INSTALL_DIR}/java") |
| 45 | else() |
| 46 | set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java") |
| 47 | endif() |
| 48 | |
| 49 | add_custom_target(ant_build ALL |
| 50 | COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} -f build.xml |
| 51 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 52 | COMMENT "Building Java library using Ant" |
| 53 | ) |
| 54 | |
| 55 | # Hook the ant install task into CMake install |
| 56 | install(CODE "execute_process( |
| 57 | COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install |
| 58 | -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} |
| 59 | -Dinstall.path=${JAVA_INSTALL_DIR} -Dinstall.javadoc.path=${JAVA_DOC_INSTALL_DIR} -f build.xml |
| 60 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 61 | )") |
| 62 | |
| 63 | if(BUILD_TESTING) |
| 64 | #add_subdirectory(test) |
| 65 | endif() |
| 66 | endif(ANDROID) |