source: CMakeLists.txt

Last change on this file was 12746, checked in by hock@…, 10 years ago

integrated the Google Testing Framework (gtest)

and wrote an Hello World test, to ensure the framework is working..

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