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 | if(ANDROID) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 21 | set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar) |
| 22 | add_custom_command( |
| 23 | OUTPUT ${THRIFT_AAR} |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 24 | COMMAND ${GRADLE_EXECUTABLE} |
| 25 | -p "${CMAKE_CURRENT_SOURCE_DIR}/android" |
| 26 | "-PbuildDir=${CMAKE_CURRENT_BINARY_DIR}/android/build" assemble |
| 27 | ) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 28 | add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 29 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 30 | else(ANDROID) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 31 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 32 | if(IS_ABSOLUTE "${LIB_INSTALL_DIR}") |
| 33 | set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java") |
| 34 | else() |
| 35 | set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java") |
| 36 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 37 | |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 38 | if(IS_ABSOLUTE "${DOC_INSTALL_DIR}") |
| 39 | set(JAVA_DOC_INSTALL_DIR "${DOC_INSTALL_DIR}/java") |
| 40 | else() |
| 41 | set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java") |
| 42 | endif() |
| 43 | |
Nobuaki Sukegawa | aa7d0d5 | 2016-02-27 03:04:34 +0900 | [diff] [blame] | 44 | add_custom_target(ThriftJava ALL |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 45 | COMMENT "Building Java library using Gradle Wrapper" |
| 46 | COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} assemble |
| 47 | --console=plain --no-daemon |
| 48 | -Prelease=true |
| 49 | -Pthrift.version=${thrift_VERSION} |
| 50 | "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" |
| 51 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 52 | ) |
| 53 | |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 54 | # Enable publishing from CMake if the publishing information is provided |
| 55 | add_custom_target(MavenPublish |
| 56 | COMMENT "Publishing Java Library to Apache Maven staging" |
| 57 | COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} clean uploadArchives |
| 58 | --console=plain --no-daemon |
| 59 | -Prelease=true |
| 60 | -Pthrift.version=${thrift_VERSION} |
| 61 | "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 62 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 63 | ) |
| 64 | |
| 65 | # Hook the CMake install process to the results from make ALL. |
| 66 | # This works best when 'make all && sudo make install/fast' is used. |
| 67 | # Using slash to end the source location to avoid copying the directory path. |
| 68 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/libs/ |
| 69 | DESTINATION ${JAVA_INSTALL_DIR} |
| 70 | FILES_MATCHING PATTERN "libthrift-${thrift_VERSION}.jar") |
| 71 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/deps/ |
| 72 | DESTINATION ${JAVA_INSTALL_DIR} |
| 73 | FILES_MATCHING PATTERN "*.jar") |
| 74 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build/docs/javadoc/ |
| 75 | DESTINATION ${JAVA_DOC_INSTALL_DIR}) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 76 | |
| 77 | if(BUILD_TESTING) |
Nobuaki Sukegawa | aa7d0d5 | 2016-02-27 03:04:34 +0900 | [diff] [blame] | 78 | add_test(NAME JavaTest |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 79 | COMMAND ${GRADLEW_EXECUTABLE} ${GRADLE_OPTS} test |
| 80 | --console=plain --no-daemon |
| 81 | -Prelease=true |
| 82 | -Pthrift.version=${thrift_VERSION} |
| 83 | "-Pbuild.dir=${CMAKE_CURRENT_BINARY_DIR}/build" |
| 84 | "-Pthrift.compiler=${THRIFT_COMPILER}" |
| 85 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
Nobuaki Sukegawa | ca93936 | 2015-11-14 00:23:40 +0900 | [diff] [blame] | 86 | endif() |
| 87 | endif(ANDROID) |