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