| 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(ariba CXX) | 
|---|
| 41 |  | 
|---|
| 42 | # Version | 
|---|
| 43 | set(ariba_VERSION_MAJOR 0) | 
|---|
| 44 | set(ariba_VERSION_MINOR 8) | 
|---|
| 45 | set(ariba_VERSION_PATCH 99) | 
|---|
| 46 | set(ariba_VERSION ${ariba_VERSION_MAJOR}.${ariba_VERSION_MINOR}.${ariba_VERSION_PATCH}) | 
|---|
| 47 |  | 
|---|
| 48 | message(STATUS "Configuring ariba version ${ariba_VERSION}") | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | list(APPEND CMAKE_MODULE_PATH "${ariba_SOURCE_DIR}/CMakeModules") | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | ## Add build type: Profiling ## | 
|---|
| 55 | SET( CMAKE_CXX_FLAGS_PROFILING "-O2 -g -pg" CACHE STRING | 
|---|
| 56 | "Flags used by the C++ compiler during profiling builds." | 
|---|
| 57 | FORCE ) | 
|---|
| 58 | SET( CMAKE_C_FLAGS_PROFILING "-O2 -g -pg" CACHE STRING | 
|---|
| 59 | "Flags used by the C compiler during profiling builds." | 
|---|
| 60 | FORCE ) | 
|---|
| 61 | SET( CMAKE_EXE_LINKER_FLAGS_PROFILING | 
|---|
| 62 | "" CACHE STRING | 
|---|
| 63 | "Flags used for linking binaries during profiling builds." | 
|---|
| 64 | FORCE ) | 
|---|
| 65 | SET( CMAKE_SHARED_LINKER_FLAGS_PROFILING | 
|---|
| 66 | "" CACHE STRING | 
|---|
| 67 | "Flags used by the shared libraries linker during profiling builds." | 
|---|
| 68 | FORCE ) | 
|---|
| 69 | MARK_AS_ADVANCED( | 
|---|
| 70 | CMAKE_CXX_FLAGS_PROFILING | 
|---|
| 71 | CMAKE_C_FLAGS_PROFILING | 
|---|
| 72 | CMAKE_EXE_LINKER_FLAGS_PROFILING | 
|---|
| 73 | CMAKE_SHARED_LINKER_FLAGS_PROFILING ) | 
|---|
| 74 | # Update the documentation string of CMAKE_BUILD_TYPE for GUIs | 
|---|
| 75 | #SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING | 
|---|
| 76 | #    "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Profiling." | 
|---|
| 77 | #    FORCE ) | 
|---|
| 78 | ## [Add build type: Profiling] ## | 
|---|
| 79 |  | 
|---|
| 80 | ## set default build type | 
|---|
| 81 | IF(NOT CMAKE_BUILD_TYPE) | 
|---|
| 82 | SET(CMAKE_BUILD_TYPE Release | 
|---|
| 83 | CACHE STRING "Choose the type of build : None Debug Release RelWithDebInfo MinSizeRel Profiling." | 
|---|
| 84 | FORCE) | 
|---|
| 85 | ENDIF(NOT CMAKE_BUILD_TYPE) | 
|---|
| 86 | message("---> Current build type is: ${CMAKE_BUILD_TYPE}") | 
|---|
| 87 |  | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|
| 91 | ## Provide some choices for CMAKE_BUILD_TYPE | 
|---|
| 92 | #set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | 
|---|
| 93 | #    "" Release Debug RelWithDebInfo MinSizeRel) | 
|---|
| 94 |  | 
|---|
| 95 | # Explicitly add BUILD_SHARED_LIBS to the user interface and default to on | 
|---|
| 96 | option(BUILD_SHARED_LIBS "Whether to build libraries shared or static" ON) | 
|---|
| 97 | mark_as_advanced(BUILD_SHARED_LIBS) | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 |  | 
|---|
| 101 | # Option to produce statically linked binaries | 
|---|
| 102 | option(BUILD_STATIC_BINS | 
|---|
| 103 | "Whether to link executables statically. | 
|---|
| 104 | If selected overrrides BUILD_SHARED_LIBS. | 
|---|
| 105 | This option has to be set BEFORE the initial creation of the CMake cache | 
|---|
| 106 | (this is only possible by using the non-interactive command line interface | 
|---|
| 107 | `cmake ../ -DBUILD_STATIC_BINS=ON`) | 
|---|
| 108 | Otherwise the library paths will not be rediscovered." | 
|---|
| 109 | OFF | 
|---|
| 110 | ) | 
|---|
| 111 |  | 
|---|
| 112 | if(DEFINED BUILD_STATIC_BINS_PREVIOUS_VALUE AND | 
|---|
| 113 | ((BUILD_STATIC_BINS_PREVIOUS_VALUE AND NOT BUILD_STATIC_BINS) OR | 
|---|
| 114 | (NOT BUILD_STATIC_BINS_PREVIOUS_VALUE AND BUILD_STATIC_BINS))) | 
|---|
| 115 | message(FATAL_ERROR | 
|---|
| 116 | "You can't set BUILD_STATIC_BINS to a different value after the " | 
|---|
| 117 | "CMake cache has been built because then the library paths will not " | 
|---|
| 118 | "be rediscovered. " | 
|---|
| 119 | "Setting this before cache creation is only possible by using the " | 
|---|
| 120 | "non-interactive command line interface: " | 
|---|
| 121 | "`cmake ../ -DBUILD_STATIC_BINS=ON`" | 
|---|
| 122 | ) | 
|---|
| 123 | endif() | 
|---|
| 124 | set(BUILD_STATIC_BINS_PREVIOUS_VALUE "${BUILD_STATIC_BINS}" CACHE INTERNAL | 
|---|
| 125 | "Internal value to detect whether the BUILD_STATIC_BINS has been previously | 
|---|
| 126 | set to a different value" | 
|---|
| 127 | ) | 
|---|
| 128 |  | 
|---|
| 129 | if(BUILD_STATIC_BINS) | 
|---|
| 130 | set(BUILD_SHARED_LIBS OFF) | 
|---|
| 131 | set(Boost_USE_STATIC_LIBS ON) | 
|---|
| 132 | set(Boost_USE_STATIC_RUNTIME ON) | 
|---|
| 133 | # Give priority to .a files (or equivalent) | 
|---|
| 134 | set(CMAKE_FIND_LIBRARY_SUFFIXES | 
|---|
| 135 | ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES}) | 
|---|
| 136 | endif(BUILD_STATIC_BINS) | 
|---|
| 137 | # End of option to produce statically linked binaries | 
|---|
| 138 |  | 
|---|
| 139 |  | 
|---|
| 140 | add_subdirectory(source) | 
|---|
| 141 | add_subdirectory(sample) | 
|---|
| 142 | add_subdirectory(docu) | 
|---|
| 143 |  | 
|---|
| 144 | # Install package information | 
|---|
| 145 | install(EXPORT ariba-targets | 
|---|
| 146 | DESTINATION lib/ariba | 
|---|
| 147 | COMPONENT Development | 
|---|
| 148 | ) | 
|---|
| 149 |  | 
|---|
| 150 | configure_file( | 
|---|
| 151 | pkg/ariba-config.cmake.in | 
|---|
| 152 | pkg/ariba-config.cmake | 
|---|
| 153 | @ONLY | 
|---|
| 154 | ) | 
|---|
| 155 |  | 
|---|
| 156 | configure_file( | 
|---|
| 157 | pkg/ariba-config-local.cmake.in | 
|---|
| 158 | ariba-config.cmake | 
|---|
| 159 | @ONLY | 
|---|
| 160 | ) | 
|---|
| 161 |  | 
|---|
| 162 | configure_file( | 
|---|
| 163 | pkg/ariba-config-version.cmake.in | 
|---|
| 164 | ariba-config-version.cmake | 
|---|
| 165 | @ONLY | 
|---|
| 166 | ) | 
|---|
| 167 |  | 
|---|
| 168 | install( | 
|---|
| 169 | FILES | 
|---|
| 170 | "${ariba_BINARY_DIR}/pkg/ariba-config.cmake" | 
|---|
| 171 | "${ariba_BINARY_DIR}/ariba-config-version.cmake" | 
|---|
| 172 | DESTINATION lib/ariba | 
|---|
| 173 | COMPONENT Development | 
|---|
| 174 | ) | 
|---|
| 175 |  | 
|---|
| 176 |  | 
|---|
| 177 |  | 
|---|
| 178 | # Packaging | 
|---|
| 179 | set(CPACK_PACKAGE_VERSION_MAJOR | 
|---|
| 180 | "${ariba_VERSION_MAJOR}" | 
|---|
| 181 | ) | 
|---|
| 182 | set(CPACK_PACKAGE_VERSION_MINOR | 
|---|
| 183 | "${ariba_VERSION_MINOR}" | 
|---|
| 184 | ) | 
|---|
| 185 | set(CPACK_PACKAGE_VERSION_PATCH | 
|---|
| 186 | "${ariba_VERSION_PATCH}" | 
|---|
| 187 | ) | 
|---|
| 188 |  | 
|---|
| 189 | set(CPACK_SYSTEM_NAME | 
|---|
| 190 | "${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}" | 
|---|
| 191 | ) | 
|---|
| 192 |  | 
|---|
| 193 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY | 
|---|
| 194 | "Ariba P2P library" | 
|---|
| 195 | ) | 
|---|
| 196 | #TODO: set(CPACK_PACKAGE_DESCRIPTION_FILE) | 
|---|
| 197 | #TODO: set(CPACK_RESOURCE_FILE_README) | 
|---|
| 198 | #TODO: set(CPACK_RESOURCE_FILE_WELCOME) | 
|---|
| 199 |  | 
|---|
| 200 | set(CPACK_PACKAGE_VENDOR | 
|---|
| 201 | "Institute of Telematics, UniversitÀt Karlsruhe (TH)" | 
|---|
| 202 | ) | 
|---|
| 203 |  | 
|---|
| 204 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "ariba-${ariba_VERSION}") | 
|---|
| 205 |  | 
|---|
| 206 | include(CPack) | 
|---|