| 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 |
|
---|
| 39 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
---|
| 40 | project(libariba)
|
---|
| 41 |
|
---|
| 42 | list(APPEND CMAKE_MODULE_PATH "${libariba_SOURCE_DIR}/../../CMakeModules")
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | ######################################################
|
---|
| 46 | ### Increment this whenever the interface changes! ###
|
---|
| 47 | ######################################################
|
---|
| 48 | set(ariba_SOVERSION 2)
|
---|
| 49 | ######################################################
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | # Find Boost
|
---|
| 53 | find_package(BoostAdditionalVersions QUIET)
|
---|
| 54 | if(NOT DEFINED BoostAdditionalVersions_FOUND)
|
---|
| 55 | message(WARNING "Could not find FindBoostAdditionalVersions.cmake. "
|
---|
| 56 | "This might cause the Boost detection to fail")
|
---|
| 57 | endif()
|
---|
| 58 | find_package(Boost 1.42.0 REQUIRED COMPONENTS system thread)
|
---|
| 59 | if(NOT Boost_FOUND)
|
---|
| 60 | message(FATAL_ERROR "Could not find Boost. "
|
---|
| 61 | "Please have a look at the Boost_* cache variables.")
|
---|
| 62 | endif(NOT Boost_FOUND)
|
---|
| 63 |
|
---|
| 64 | mark_as_advanced(Boost_DIR)
|
---|
| 65 | include(BoostPthreadWorkaround)
|
---|
| 66 |
|
---|
| 67 | include_directories(${Boost_INCLUDE_DIRS})
|
---|
| 68 | list(APPEND ariba_LINK_LIBRARIES ${Boost_LIBRARIES})
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | # Find gmp
|
---|
| 72 | find_package(GMP REQUIRED)
|
---|
| 73 | if(NOT GMP_FOUND)
|
---|
| 74 | message(FATAL_ERROR "Could not find GMP. "
|
---|
| 75 | "Please have a look at the GMP_* cache variables.")
|
---|
| 76 | endif(NOT GMP_FOUND)
|
---|
| 77 | include_directories(${GMP_INCLUDE_DIRS})
|
---|
| 78 | list(APPEND ariba_LINK_LIBRARIES ${GMP_LIBRARIES})
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | # Bluetooth support?
|
---|
| 82 | find_package(LibBluetooth)
|
---|
| 83 | if(NOT LIBBLUETOOTH_FOUND)
|
---|
| 84 | message(STATUS "Couldn't find libbluetooth. "
|
---|
| 85 | "Will build ariba withouth bluetooth support")
|
---|
| 86 | endif()
|
---|
| 87 | include(CMakeDependentOption)
|
---|
| 88 | cmake_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 | )
|
---|
| 94 | if(ENABLE_BLUETOOTH)
|
---|
| 95 | set(HAVE_LIBBLUETOOTH TRUE)
|
---|
| 96 | include_directories("${LIBBLUETOOTH_INCLUDE_DIR}")
|
---|
| 97 | list(APPEND ariba_LINK_LIBRARIES ${LIBBLUETOOTH_LIBRARIES})
|
---|
| 98 | endif(ENABLE_BLUETOOTH)
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | # Avahi support?
|
---|
| 102 | find_package(Avahi COMPONENTS client common)
|
---|
| 103 | if(NOT AVAHI_FOUND)
|
---|
| 104 | message(STATUS "Couldn't find Avahi. "
|
---|
| 105 | "Will build ariba withouth multicast DNS support")
|
---|
| 106 | endif()
|
---|
| 107 | cmake_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 | )
|
---|
| 113 | if(ENABLE_AVAHI)
|
---|
| 114 | set(HAVE_AVAHI TRUE)
|
---|
| 115 | include_directories(${AVAHI_INCLUDE_DIRS})
|
---|
| 116 | list(APPEND ariba_LINK_LIBRARIES ${AVAHI_LIBRARIES})
|
---|
| 117 | endif(ENABLE_AVAHI)
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | # Log4Cxx support?
|
---|
| 121 | find_package(Log4Cxx)
|
---|
| 122 | if(NOT LOG4CXX_FOUND)
|
---|
| 123 | message(STATUS "Couldn't find Log4Cxx. "
|
---|
| 124 | "Will build ariba withouth extended logging support")
|
---|
| 125 | endif()
|
---|
| 126 | cmake_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 | )
|
---|
| 132 | if(ENABLE_LOG4CXX)
|
---|
| 133 | set(HAVE_LOG4CXX TRUE)
|
---|
| 134 | include_directories(${LOG4CXX_INCLUDE_DIRS})
|
---|
| 135 | list(APPEND ariba_LINK_LIBRARIES ${LOG4CXX_LIBRARIES})
|
---|
| 136 | endif(ENABLE_LOG4CXX)
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | set(add_headers_INSTALL_DIR include/ariba/)
|
---|
| 141 | set(add_headers_INSTALL_COMPONENT Development)
|
---|
| 142 | set(add_headers_VAR libariba_HEADERS)
|
---|
| 143 | set(add_sources_VAR libariba_SOURCES)
|
---|
| 144 |
|
---|
| 145 | # Voodoo to collect the source files from the subdirectories
|
---|
| 146 | function(add_subdir_sources_helper subdir)
|
---|
| 147 | set(CURRENT_SOURCE_DIR "${CURRENT_SOURCE_DIR}${subdir}/")
|
---|
| 148 | set(add_headers_INSTALL_DIR "${add_headers_INSTALL_DIR}${subdir}/")
|
---|
| 149 | add_subdirectory(${subdir})
|
---|
| 150 | set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
|
---|
| 151 | set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
|
---|
| 152 | endfunction(add_subdir_sources_helper subdir)
|
---|
| 153 |
|
---|
| 154 | macro(add_subdir_sources subdirs)
|
---|
| 155 | foreach(subdir ${subdirs} ${ARGN})
|
---|
| 156 | add_subdir_sources_helper(${subdir})
|
---|
| 157 | endforeach(subdir ${subdirs} ${ARGN})
|
---|
| 158 | set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
|
---|
| 159 | set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
|
---|
| 160 | endmacro(add_subdir_sources subdirs)
|
---|
| 161 |
|
---|
| 162 | macro(add_headers sources)
|
---|
| 163 | foreach(source ${sources} ${ARGN})
|
---|
| 164 | list(APPEND ${add_headers_VAR} "${CURRENT_SOURCE_DIR}${source}")
|
---|
| 165 | endforeach(source ${sources} ${ARGN})
|
---|
| 166 |
|
---|
| 167 | install(FILES ${sources} ${ARGN}
|
---|
| 168 | DESTINATION "${add_headers_INSTALL_DIR}"
|
---|
| 169 | COMPONENT "${add_headers_INSTALL_COMPONENT}"
|
---|
| 170 | )
|
---|
| 171 |
|
---|
| 172 | set(${add_headers_VAR} ${${add_headers_VAR}} PARENT_SCOPE)
|
---|
| 173 | endmacro(add_headers sources)
|
---|
| 174 |
|
---|
| 175 | macro(add_sources sources)
|
---|
| 176 | foreach(source ${sources} ${ARGN})
|
---|
| 177 | list(APPEND ${add_sources_VAR} "${CURRENT_SOURCE_DIR}${source}")
|
---|
| 178 | endforeach(source ${sources} ${ARGN})
|
---|
| 179 | set(${add_sources_VAR} ${${add_sources_VAR}} PARENT_SCOPE)
|
---|
| 180 | endmacro(add_sources sources)
|
---|
| 181 |
|
---|
| 182 |
|
---|
| 183 | # Headers to be exported
|
---|
| 184 | add_headers(
|
---|
| 185 | ariba.h
|
---|
| 186 | # AribaModule.h
|
---|
| 187 | CommunicationListener.h
|
---|
| 188 | DataMessage.h
|
---|
| 189 | Identifiers.h
|
---|
| 190 | LinkProperties.h
|
---|
| 191 | Message.h
|
---|
| 192 | Module.h
|
---|
| 193 | Name.h
|
---|
| 194 | Node.h
|
---|
| 195 | NodeListener.h
|
---|
| 196 | SideportListener.h
|
---|
| 197 | SpoVNetProperties.h
|
---|
| 198 | )
|
---|
| 199 |
|
---|
| 200 | add_sources(
|
---|
| 201 | # AribaModule.cpp
|
---|
| 202 | CommunicationListener.cpp
|
---|
| 203 | DataMessage.cpp
|
---|
| 204 | Identifiers.cpp
|
---|
| 205 | LinkProperties.cpp
|
---|
| 206 | Module.cpp
|
---|
| 207 | Name.cpp
|
---|
| 208 | Node.cpp
|
---|
| 209 | NodeListener.cpp
|
---|
| 210 | SideportListener.cpp
|
---|
| 211 | SpoVNetProperties.cpp
|
---|
| 212 | )
|
---|
| 213 |
|
---|
| 214 | # Can't use add_subdir_sources() here because we want it in this scope not
|
---|
| 215 | # in our parent's scope
|
---|
| 216 | add_subdir_sources_helper(communication)
|
---|
| 217 | add_subdir_sources_helper(overlay)
|
---|
| 218 | add_subdir_sources_helper(utility)
|
---|
| 219 |
|
---|
| 220 |
|
---|
| 221 | if(CMAKE_BUILD_TYPE)
|
---|
| 222 | if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
|
---|
| 223 | set(DEBUG ON)
|
---|
| 224 | endif()
|
---|
| 225 | endif()
|
---|
| 226 |
|
---|
| 227 | option(HAVE_MAEMO
|
---|
| 228 | "Whether we compile for the maemo platform" #TODO: maybe detect automatically
|
---|
| 229 | OFF
|
---|
| 230 | )
|
---|
| 231 |
|
---|
| 232 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
|
---|
| 233 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
---|
| 234 |
|
---|
| 235 | # Configure the template file
|
---|
| 236 | configure_file(
|
---|
| 237 | config.h.in
|
---|
| 238 | config.h
|
---|
| 239 | )
|
---|
| 240 | include_directories("${CMAKE_CURRENT_BINARY_DIR}/..")
|
---|
| 241 | list(APPEND libariba_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
---|
| 242 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config.h"
|
---|
| 243 | DESTINATION "${add_headers_INSTALL_DIR}"
|
---|
| 244 | COMPONENT "${add_headers_INSTALL_COMPONENT}"
|
---|
| 245 | )
|
---|
| 246 |
|
---|
| 247 | # Add the parent directory to the includes because we reference headers with
|
---|
| 248 | # "ariba/path/to/file" all the time
|
---|
| 249 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | # Compile the actual library
|
---|
| 253 |
|
---|
| 254 | include(BuildSharedAndStaticLib)
|
---|
| 255 |
|
---|
| 256 | set(ariba_SOURCES ${libariba_SOURCES} ${libariba_HEADERS})
|
---|
| 257 | # ariba_LINK_LIBRARIES, ariba_VERSION and ariba_SOVERSION already defined
|
---|
| 258 |
|
---|
| 259 | build_shared_and_static_libs(ariba)
|
---|
| 260 |
|
---|
| 261 |
|
---|
| 262 | # Install binaries
|
---|
| 263 | install(TARGETS ariba ${ariba_STATIC_TARGET} EXPORT ariba-targets
|
---|
| 264 | LIBRARY DESTINATION lib COMPONENT Runtime
|
---|
| 265 | ARCHIVE DESTINATION lib COMPONENT Development
|
---|
| 266 | RUNTIME DESTINATION bin COMPONENT Runtime
|
---|
| 267 | )
|
---|
| 268 |
|
---|
| 269 |
|
---|
| 270 | # Make libariba usable from build tree
|
---|
| 271 | export(TARGETS ariba ${ariba_STATIC_TARGET} FILE ariba-exports.cmake)
|
---|
| 272 |
|
---|
| 273 | if(ariba_BINARY_DIR)
|
---|
| 274 | export(TARGETS ariba ${ariba_STATIC_TARGET}
|
---|
| 275 | FILE "${ariba_BINARY_DIR}/ariba-exports.cmake")
|
---|
| 276 | endif(ariba_BINARY_DIR)
|
---|