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 | |
| 20 | |
| 21 | set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE) |
| 22 | |
| 23 | |
| 24 | macro(ADD_LIBRARY_THRIFT name) |
| 25 | |
| 26 | if(WITH_SHARED_LIB) |
| 27 | add_library(${name} SHARED ${ARGN}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 28 | set_target_properties(${name} PROPERTIES |
| 29 | OUTPUT_NAME ${name} |
| 30 | VERSION ${thrift_VERSION} |
| 31 | SOVERSION ${thrift_VERSION} ) |
| 32 | #set_target_properties(${name} PROPERTIES PUBLIC_HEADER "${thriftcpp_HEADERS}") |
| 33 | install(TARGETS ${name} |
| 34 | RUNTIME DESTINATION "${BIN_INSTALL_DIR}" |
| 35 | LIBRARY DESTINATION "${LIB_INSTALL_DIR}" |
| 36 | ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" |
| 37 | PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}") |
| 38 | endif() |
| 39 | |
| 40 | if(WITH_STATIC_LIB) |
| 41 | add_library(${name}_static STATIC ${ARGN}) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 42 | set_target_properties(${name}_static PROPERTIES |
| 43 | OUTPUT_NAME ${name}${STATIC_POSTFIX} |
| 44 | VERSION ${thrift_VERSION} |
| 45 | SOVERSION ${thrift_VERSION} ) |
| 46 | install(TARGETS ${name}_static |
| 47 | RUNTIME DESTINATION "${BIN_INSTALL_DIR}" |
| 48 | LIBRARY DESTINATION "${LIB_INSTALL_DIR}" |
| 49 | ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" |
| 50 | PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}") |
| 51 | endif() |
| 52 | |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 53 | endmacro(ADD_LIBRARY_THRIFT) |
| 54 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 55 | |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 56 | macro(TARGET_INCLUDE_DIRECTORIES_THRIFT name) |
| 57 | |
| 58 | if(WITH_SHARED_LIB) |
| 59 | target_include_directories(${name} ${ARGN}) |
| 60 | endif() |
| 61 | |
| 62 | if(WITH_STATIC_LIB) |
| 63 | target_include_directories(${name}_static ${ARGN}) |
| 64 | endif() |
| 65 | |
| 66 | endmacro(TARGET_INCLUDE_DIRECTORIES_THRIFT) |
| 67 | |
| 68 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 69 | macro(TARGET_LINK_LIBRARIES_THRIFT name) |
| 70 | |
| 71 | if(WITH_SHARED_LIB) |
| 72 | target_link_libraries(${name} ${ARGN}) |
| 73 | endif() |
| 74 | |
| 75 | if(WITH_STATIC_LIB) |
| 76 | target_link_libraries(${name}_static ${ARGN}) |
| 77 | endif() |
| 78 | |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 79 | endmacro(TARGET_LINK_LIBRARIES_THRIFT) |
| 80 | |
| 81 | |
| 82 | macro(LINK_AGAINST_THRIFT_LIBRARY target libname) |
| 83 | |
| 84 | if (WITH_SHARED_LIB) |
| 85 | target_link_libraries(${target} ${libname}) |
| 86 | elseif (WITH_STATIC_LIB) |
| 87 | target_link_libraries(${target} ${libname}_static) |
| 88 | else() |
| 89 | message(FATAL "Not linking with shared or static libraries?") |
| 90 | endif() |
| 91 | |
| 92 | endmacro(LINK_AGAINST_THRIFT_LIBRARY) |
| 93 | |
| 94 | |
| 95 | macro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY target libname) |
| 96 | |
| 97 | if(WITH_SHARED_LIB) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 98 | target_link_libraries(${target} ${ARGN} ${libname}) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 99 | endif() |
| 100 | |
| 101 | if(WITH_STATIC_LIB) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 102 | target_link_libraries(${target}_static ${ARGN} ${libname}_static) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 103 | endif() |
| 104 | |
| 105 | endmacro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY) |