| 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 1)
|
---|
| 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_VAR libariba_HEADERS)
|
---|
| 141 | set(add_sources_VAR libariba_SOURCES)
|
---|
| 142 |
|
---|
| 143 | # Voodoo to collect the source files from the subdirectories
|
---|
| 144 | function(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)
|
---|
| 149 | endfunction(add_subdir_sources_helper subdir)
|
---|
| 150 |
|
---|
| 151 | macro(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)
|
---|
| 157 | endmacro(add_subdir_sources subdirs)
|
---|
| 158 |
|
---|
| 159 | macro(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)
|
---|
| 164 | endmacro(add_headers sources)
|
---|
| 165 |
|
---|
| 166 | macro(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)
|
---|
| 171 | endmacro(add_sources sources)
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | # Headers to be exported
|
---|
| 175 | set(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 |
|
---|
| 191 | set(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
|
---|
| 207 | add_subdir_sources_helper(communication)
|
---|
| 208 | add_subdir_sources_helper(overlay)
|
---|
| 209 | add_subdir_sources_helper(utility)
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 | if(CMAKE_BUILD_TYPE)
|
---|
| 213 | if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
|
---|
| 214 | set(DEBUG ON)
|
---|
| 215 | endif()
|
---|
| 216 | endif()
|
---|
| 217 |
|
---|
| 218 | option(HAVE_MAEMO
|
---|
| 219 | "Whether we compile for the maemo platform" #TODO: maybe detect automatically
|
---|
| 220 | OFF
|
---|
| 221 | )
|
---|
| 222 |
|
---|
| 223 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
|
---|
| 224 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
---|
| 225 |
|
---|
| 226 | # Configure the template file
|
---|
| 227 | configure_file(
|
---|
| 228 | config.h.in
|
---|
| 229 | config.h
|
---|
| 230 | )
|
---|
| 231 | include_directories("${CMAKE_CURRENT_BINARY_DIR}/..")
|
---|
| 232 | list(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
|
---|
| 236 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
|
---|
| 237 |
|
---|
| 238 |
|
---|
| 239 | # Compile the actual library
|
---|
| 240 |
|
---|
| 241 | include(BuildSharedAndStaticLib)
|
---|
| 242 |
|
---|
| 243 | set(ariba_SOURCES ${libariba_SOURCES} ${libariba_HEADERS})
|
---|
| 244 | # ariba_LINK_LIBRARIES, ariba_VERSION and ariba_SOVERSION already defined
|
---|
| 245 |
|
---|
| 246 | build_shared_and_static_libs(ariba)
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | # Installation stuff
|
---|
| 250 | install(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 |
|
---|
| 256 | install(FILES ${libariba_HEADERS}
|
---|
| 257 | DESTINATION include/ariba
|
---|
| 258 | COMPONENT Development
|
---|
| 259 | )
|
---|
| 260 |
|
---|
| 261 | # Make libariba usable from build tree
|
---|
| 262 | export(TARGETS ariba ${ariba_STATIC_TARGET} FILE ariba-exports.cmake)
|
---|
| 263 |
|
---|
| 264 | if(ariba_BINARY_DIR)
|
---|
| 265 | export(TARGETS ariba ${ariba_STATIC_TARGET}
|
---|
| 266 | FILE "${ariba_BINARY_DIR}/ariba-exports.cmake")
|
---|
| 267 | endif(ariba_BINARY_DIR)
|
---|