blob: f837f9482f432b9a008e236630077647b4d98b9f [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
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
21set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE)
22
23
24macro(ADD_LIBRARY_THRIFT name)
25
26if(WITH_SHARED_LIB)
27 add_library(${name} SHARED ${ARGN})
Pascal Bachd5f87e12014-12-12 15:59:17 +010028 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}")
38endif()
39
40if(WITH_STATIC_LIB)
41 add_library(${name}_static STATIC ${ARGN})
Pascal Bachd5f87e12014-12-12 15:59:17 +010042 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}")
51endif()
52
Jim King9de9b1f2015-04-30 16:03:34 -040053endmacro(ADD_LIBRARY_THRIFT)
54
Pascal Bachd5f87e12014-12-12 15:59:17 +010055
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090056macro(TARGET_INCLUDE_DIRECTORIES_THRIFT name)
57
58if(WITH_SHARED_LIB)
59 target_include_directories(${name} ${ARGN})
60endif()
61
62if(WITH_STATIC_LIB)
63 target_include_directories(${name}_static ${ARGN})
64endif()
65
66endmacro(TARGET_INCLUDE_DIRECTORIES_THRIFT)
67
68
Pascal Bachd5f87e12014-12-12 15:59:17 +010069macro(TARGET_LINK_LIBRARIES_THRIFT name)
70
71if(WITH_SHARED_LIB)
72 target_link_libraries(${name} ${ARGN})
73endif()
74
75if(WITH_STATIC_LIB)
76 target_link_libraries(${name}_static ${ARGN})
77endif()
78
Jim King9de9b1f2015-04-30 16:03:34 -040079endmacro(TARGET_LINK_LIBRARIES_THRIFT)
80
81
82macro(LINK_AGAINST_THRIFT_LIBRARY target libname)
83
84if (WITH_SHARED_LIB)
85 target_link_libraries(${target} ${libname})
86elseif (WITH_STATIC_LIB)
87 target_link_libraries(${target} ${libname}_static)
88else()
89 message(FATAL "Not linking with shared or static libraries?")
90endif()
91
92endmacro(LINK_AGAINST_THRIFT_LIBRARY)
93
94
95macro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY target libname)
96
97if(WITH_SHARED_LIB)
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090098 target_link_libraries(${target} ${ARGN} ${libname})
Jim King9de9b1f2015-04-30 16:03:34 -040099endif()
100
101if(WITH_STATIC_LIB)
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +0900102 target_link_libraries(${target}_static ${ARGN} ${libname}_static)
Jim King9de9b1f2015-04-30 16:03:34 -0400103endif()
104
105endmacro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY)