source: CMakeLists.txt@ 12458

Last change on this file since 12458 was 12349, checked in by s_taenzer@…, 11 years ago

CMake: Clean up build configuration stuff

File size: 6.2 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
50
51list(APPEND CMAKE_MODULE_PATH "${ariba_SOURCE_DIR}/CMakeModules")
52
53
54# Add build type: Profiling
55SET( CMAKE_CXX_FLAGS_PROFILING "-O2 -g -pg" CACHE STRING
56 "Flags used by the C++ compiler during profiling builds."
57 FORCE )
58SET( CMAKE_C_FLAGS_PROFILING "-O2 -g -pg" CACHE STRING
59 "Flags used by the C compiler during profiling builds."
60 FORCE )
61SET( CMAKE_EXE_LINKER_FLAGS_PROFILING
62 "" CACHE STRING
63 "Flags used for linking binaries during profiling builds."
64 FORCE )
65SET( CMAKE_SHARED_LINKER_FLAGS_PROFILING
66 "" CACHE STRING
67 "Flags used by the shared libraries linker during profiling builds."
68 FORCE )
69MARK_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
76IF(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)
80ENDIF(NOT CMAKE_BUILD_TYPE)
81message(STATUS "Current build type is: ${CMAKE_BUILD_TYPE}")
82
83## Provide some choices for CMAKE_BUILD_TYPE
84set_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
90option(BUILD_SHARED_LIBS "Whether to build libraries shared or static" ON)
91mark_as_advanced(BUILD_SHARED_LIBS)
92
93
94
95# Option to produce statically linked binaries
96option(BUILD_STATIC_BINS
97 "Whether to link executables statically.
98If selected overrrides BUILD_SHARED_LIBS.
99This 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`)
102Otherwise the library paths will not be rediscovered."
103 OFF
104 )
105
106if(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 )
117endif()
118set(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
123if(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})
130endif(BUILD_STATIC_BINS)
131# End of option to produce statically linked binaries
132
133
134add_subdirectory(source)
135add_subdirectory(sample)
136add_subdirectory(docu)
137
138# Install package information
139install(EXPORT ariba-targets
140 DESTINATION lib/ariba
141 COMPONENT Development
142 )
143
144configure_file(
145 pkg/ariba-config.cmake.in
146 pkg/ariba-config.cmake
147 @ONLY
148 )
149
150configure_file(
151 pkg/ariba-config-local.cmake.in
152 ariba-config.cmake
153 @ONLY
154 )
155
156configure_file(
157 pkg/ariba-config-version.cmake.in
158 ariba-config-version.cmake
159 @ONLY
160 )
161
162install(
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
173set(CPACK_PACKAGE_VERSION_MAJOR
174 "${ariba_VERSION_MAJOR}"
175 )
176set(CPACK_PACKAGE_VERSION_MINOR
177 "${ariba_VERSION_MINOR}"
178 )
179set(CPACK_PACKAGE_VERSION_PATCH
180 "${ariba_VERSION_PATCH}"
181 )
182
183set(CPACK_SYSTEM_NAME
184 "${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}"
185 )
186
187set(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
194set(CPACK_PACKAGE_VENDOR
195 "Institute of Telematics, UniversitÀt Karlsruhe (TH)"
196 )
197
198set(CPACK_SOURCE_PACKAGE_FILE_NAME "ariba-${ariba_VERSION}")
199
200include(CPack)
Note: See TracBrowser for help on using the repository browser.