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