close Warning: Can't use blame annotator:
No changeset 10668 in the repository

source: source/ariba/CMakeLists.txt@ 10752

Last change on this file since 10752 was 10700, checked in by Michael Tänzer, 12 years ago

Merge CMake branch into trunk

File size: 8.2 KB
RevLine 
1# [License]
2# The Ariba-Underlay Copyright
3#
4# Copyright (c) 2008-2012, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5#
6# Institute of Telematics
7# UniversitÀt Karlsruhe (TH)
8# Zirkel 2, 76128 Karlsruhe
9# Germany
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions are
13# met:
14#
15# 1. Redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution.
20#
21# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
25# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33# The views and conclusions contained in the software and documentation
34# are those of the authors and should not be interpreted as representing
35# official policies, either expressed or implied, of the Institute of
36# Telematics.
37# [License]
38
39cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
40project(libariba)
41
42list(APPEND CMAKE_MODULE_PATH "${libariba_SOURCE_DIR}/../../CMakeModules")
43
44
45######################################################
46### Increment this whenever the interface changes! ###
47######################################################
48set(ariba_SOVERSION 1)
49######################################################
50
51
52# Find Boost
53find_package(BoostAdditionalVersions QUIET)
54if(NOT DEFINED BoostAdditionalVersions_FOUND)
55 message(WARNING "Could not find FindBoostAdditionalVersions.cmake. "
56 "This might cause the Boost detection to fail")
57endif()
58find_package(Boost 1.42.0 REQUIRED COMPONENTS system thread)
59if(NOT Boost_FOUND)
60 message(FATAL_ERROR "Could not find Boost. "
61 "Please have a look at the Boost_* cache variables.")
62endif(NOT Boost_FOUND)
63
64mark_as_advanced(Boost_DIR)
65include(BoostPthreadWorkaround)
66
67include_directories(${Boost_INCLUDE_DIRS})
68list(APPEND ariba_LINK_LIBRARIES ${Boost_LIBRARIES})
69
70
71# Find gmp
72find_package(GMP REQUIRED)
73if(NOT GMP_FOUND)
74 message(FATAL_ERROR "Could not find GMP. "
75 "Please have a look at the GMP_* cache variables.")
76endif(NOT GMP_FOUND)
77include_directories(${GMP_INCLUDE_DIRS})
78list(APPEND ariba_LINK_LIBRARIES ${GMP_LIBRARIES})
79
80
81# Bluetooth support?
82find_package(LibBluetooth)
83if(NOT LIBBLUETOOTH_FOUND)
84 message(STATUS "Couldn't find libbluetooth. "
85 "Will build ariba withouth bluetooth support")
86endif()
87include(CMakeDependentOption)
88cmake_dependent_option(ENABLE_BLUETOOTH
89 "Enable bluetooth support" #doc
90 ON # default value
91 "LIBBLUETOOTH_FOUND" # only show if this evaluates to true
92 OFF # value if the condition is not met
93 )
94if(ENABLE_BLUETOOTH)
95 set(HAVE_LIBBLUETOOTH TRUE)
96 include_directories("${LIBBLUETOOTH_INCLUDE_DIR}")
97 list(APPEND ariba_LINK_LIBRARIES ${LIBBLUETOOTH_LIBRARIES})
98endif(ENABLE_BLUETOOTH)
99
100
101# Avahi support?
102find_package(Avahi COMPONENTS client common)
103if(NOT AVAHI_FOUND)
104 message(STATUS "Couldn't find Avahi. "
105 "Will build ariba withouth multicast DNS support")
106endif()
107cmake_dependent_option(ENABLE_AVAHI
108 "Enable Avahi (multicast DNS) support" #doc
109 ON # default value
110 "AVAHI_FOUND" # only show if this evaluates to true
111 OFF # value if the condition is not met
112 )
113if(ENABLE_AVAHI)
114 set(HAVE_AVAHI TRUE)
115 include_directories(${AVAHI_INCLUDE_DIRS})
116 list(APPEND ariba_LINK_LIBRARIES ${AVAHI_LIBRARIES})
117endif(ENABLE_AVAHI)
118
119
120# Log4Cxx support?
121find_package(Log4Cxx)
122if(NOT LOG4CXX_FOUND)
123 message(STATUS "Couldn't find Log4Cxx. "
124 "Will build ariba withouth extended logging support")
125endif()
126cmake_dependent_option(ENABLE_LOG4CXX
127 "Enable Log4Cxx (extended logging) support" #doc
128 ON # default value
129 "LOG4CXX_FOUND" # only show if this evaluates to true
130 OFF # value if the condition is not met
131 )
132if(ENABLE_LOG4CXX)
133 set(HAVE_LOG4CXX TRUE)
134 include_directories(${LOG4CXX_INCLUDE_DIRS})
135 list(APPEND ariba_LINK_LIBRARIES ${LOG4CXX_LIBRARIES})
136endif(ENABLE_LOG4CXX)
137
138
139
140set(add_headers_VAR libariba_HEADERS)
141set(add_sources_VAR libariba_SOURCES)
142
143# Voodoo to collect the source files from the subdirectories
144function(add_subdir_sources_helper subdir)
145 set(CURRENT_SOURCE_DIR "${CURRENT_SOURCE_DIR}${subdir}/")
146 add_subdirectory(${subdir})
147 set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
148 set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
149endfunction(add_subdir_sources_helper subdir)
150
151macro(add_subdir_sources subdirs)
152 foreach(subdir ${subdirs} ${ARGN})
153 add_subdir_sources_helper(${subdir})
154 endforeach(subdir ${subdirs} ${ARGN})
155 set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
156 set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
157endmacro(add_subdir_sources subdirs)
158
159macro(add_headers sources)
160 foreach(source ${sources} ${ARGN})
161 list(APPEND ${add_headers_VAR} "${CURRENT_SOURCE_DIR}${source}")
162 endforeach(source ${sources} ${ARGN})
163 set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
164endmacro(add_headers sources)
165
166macro(add_sources sources)
167 foreach(source ${sources} ${ARGN})
168 list(APPEND ${add_sources_VAR} "${CURRENT_SOURCE_DIR}${source}")
169 endforeach(source ${sources} ${ARGN})
170 set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
171endmacro(add_sources sources)
172
173
174# Headers to be exported
175set(libariba_HEADERS
176 ariba.h
177 AribaModule.h
178 CommunicationListener.h
179 DataMessage.h
180 Identifiers.h
181 LinkProperties.h
182 Message.h
183 Module.h
184 Name.h
185 Node.h
186 NodeListener.h
187 SideportListener.h
188 SpoVNetProperties.h
189 )
190
191set(libariba_SOURCES
192 AribaModule.cpp
193 CommunicationListener.cpp
194 DataMessage.cpp
195 Identifiers.cpp
196 LinkProperties.cpp
197 Module.cpp
198 Name.cpp
199 Node.cpp
200 NodeListener.cpp
201 SideportListener.cpp
202 SpoVNetProperties.cpp
203 )
204
205# Can't use add_subdir_sources() here because we want it in this scope not
206# in our parent's scope
207add_subdir_sources_helper(communication)
208add_subdir_sources_helper(overlay)
209add_subdir_sources_helper(utility)
210
211
212if(CMAKE_BUILD_TYPE)
213 if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
214 set(DEBUG ON)
215 endif()
216endif()
217
218option(HAVE_MAEMO
219 "Whether we compile for the maemo platform" #TODO: maybe detect automatically
220 OFF
221 )
222
223set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
224set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
225
226# Configure the template file
227configure_file(
228 config.h.in
229 config.h
230 )
231include_directories("${CMAKE_CURRENT_BINARY_DIR}/..")
232list(APPEND libariba_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/config.h")
233
234# Add the parent directory to the includes because we reference headers with
235# "ariba/path/to/file" all the time
236include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
237
238
239# Compile the actual library
240
241include(BuildSharedAndStaticLib)
242
243set(ariba_SOURCES ${libariba_SOURCES} ${libariba_HEADERS})
244# ariba_LINK_LIBRARIES, ariba_VERSION and ariba_SOVERSION already defined
245
246build_shared_and_static_libs(ariba)
247
248
249# Installation stuff
250install(TARGETS ariba ${ariba_STATIC_TARGET} EXPORT ariba-targets
251 LIBRARY DESTINATION lib COMPONENT Runtime
252 ARCHIVE DESTINATION lib COMPONENT Development
253 RUNTIME DESTINATION bin COMPONENT Runtime
254 )
255
256install(FILES ${libariba_HEADERS}
257 DESTINATION include/ariba
258 COMPONENT Development
259 )
260
261# Make libariba usable from build tree
262export(TARGETS ariba ${ariba_STATIC_TARGET} FILE ariba-exports.cmake)
263
264if(ariba_BINARY_DIR)
265 export(TARGETS ariba ${ariba_STATIC_TARGET}
266 FILE "${ariba_BINARY_DIR}/ariba-exports.cmake")
267endif(ariba_BINARY_DIR)
Note: See TracBrowser for help on using the repository browser.