Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
###############################################################################
# The MpiUncertainty Application
################################################################################
# Define CMake compatibility version
cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
# The name of this project.
project (MpiUncertainty)
include (${CONFIGPATH})
################################################################################
# Installation items
################################################################################
set (MPIUNCERTAINTY_PATH_BINS "usr/bin")
set (MPIUNCERTAINTY_PATH_CONFIG "etc/bbque")
set (MPIUNCERTAINTY_PATH_RECIPES "etc/bbque/recipes")
set (MPIUNCERTAINTY_PATH_DOCS "usr/share/bbque/mpiuncertainty")
set (CMAKE_INSTALL_RPATH "${CONFIG_BOSP_RUNTIME_PATH}/lib/bbque:${CONFIG_BOSP_RUNTIME_PATH}/lib")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
################################################################################
# Common initialization settings
################################################################################
# Load additional CMake modules
list (APPEND CMAKE_MODULE_PATH
"${BOSP_CMAKE_MODULES}")
list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/.cmake")
# Make sure the compiler can find include files
include_directories (
${PROJECT_BINARY_DIR}/include
${PROJECT_SOURCE_DIR}/include
)
message ( STATUS )
message ( STATUS "Checking dependencies..." )
# Setup the source tree versioning number
include (GetGitRevisionDescription)
git_describe(GIT_SHA1)
set (VERSION "${GIT_SHA1}")
# Check if running un UNIX like systems
if (UNIX)
add_definitions(-DUNIX)
endif(UNIX)
################################################################################
# Build version specific configurations
################################################################################
# Choose the type of build, options are:
# None Debug Release RelWithDebInfo MinSizeRel
# Set default release version to RELEASE
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo)
endif (NOT CMAKE_BUILD_TYPE)
# Add flags common to all builds
set (BOSP_CPP11 "0x")
if (GCC_TAG GREATER "46")
set (BOSP_CPP11 "11")
endif (GCC_TAG GREATER "46")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++${BOSP_CPP11} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGCC_VERSION=${GCC_VERSION}")
# These are used to clean-up unreferenced libraries symbols
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--gc-sections")
# Add "Generic-Linux" specific flags
if (CONFIG_TARGET_LINUX_NATIVE)
set (BBQUE_TARGET_OS "Native-Linux")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif (CONFIG_TARGET_LINUX_NATIVE)
# Add "ARM-Linux" specific flags
if (CONFIG_TARGET_LINUX_ARM)
set (BBQUE_TARGET_OS "ARM-Linux")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif (CONFIG_TARGET_LINUX_ARM)
# Add "Android-Linux" specific flags
if (CONFIG_TARGET_ANDROID)
set (BBQUE_TARGET_OS "Android-Linux")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I../../../out/include -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -D__STDINT_LIMITS -D_GLIBCXX_USE_C99_STDINT_TR1 -D__BIONIC__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fexceptions -frtti -mthumb -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack")
# -ffunction-sections -fdata-sections -Wl,--gc-sections - REMOVED becaus of missing symbols
endif (CONFIG_TARGET_ANDROID)
# Check target bitness
set (BBQUE_TARGET_ARCH 32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (BBQUE_TARGET_ARCH 64)
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (BBQUE_BUILD_FLAVOR
"${BBQUE_TARGET_OS} (${BBQUE_TARGET_ARCH}bit - ${CMAKE_BUILD_TYPE})")
# Options for build version: DEBUG
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wextra -pedantic -DBBQUE_DEBUG -DDEBUG")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set (BBQUE_DEBUG ON)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
# Options for build version: DESKTOP RELEASE
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
# Options for build version: EMBEDDED RELEASE
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
################################################################################
# Installation locations
################################################################################
# set default install prefix to project root directory
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/out" )
endif (CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
################################################################################
# Lookup for library dependencies
################################################################################
# Force usage of BOSP provided BOOST installation
set (Boost_NO_SYSTEM_PATHS ON)
set (BOOST_ROOT ${CMAKE_INSTALL_PREFIX})
set (BOOST_INCLUDEDIR ${CMAKE_INSTALL_PREFIX})
# Check for required libs and packages (headers + lib)
find_package(Boost 1.45.0 REQUIRED program_options)
# Add compilation dependencies
include_directories(
${Boost_INCLUDE_DIRS}
)
# Add linking dependencies
link_directories(
${Boost_LIBRARY_DIRS}
)
################################################################################
# Subdirectories analysis
################################################################################
## Add package version definition
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.cc.in"
"${PROJECT_BINARY_DIR}/src/version.cc" @ONLY
)
# Recurse into project subfolders
add_subdirectory (src)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/recipes/"
DESTINATION "${MPIUNCERTAINTY_PATH_RECIPES}"
FILES_MATCHING PATTERN "*.recipe")
################################################################################
# Doxygen Documentation
################################################################################
# check if doxygen is even installed
find_package(Doxygen)
if (DOXYGEN_FOUND STREQUAL "NO")
message(FATAL_ERROR "Doxygen not found. "
"Please get a copy http://www.doxygen.org")
endif (DOXYGEN_FOUND STREQUAL "NO")
# prepare doxygen configuration file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# add doxygen as target
add_custom_target (doxygen ${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# cleanup $build/api-doc on "make clean"
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES api-doc)
# add doxygen as dependency to doc-target
get_target_property (DOC_TARGET doc TYPE)
if (NOT DOC_TARGET)
add_custom_target(doc)
endif ()
add_dependencies (doc doxygen)
# install HTML API documentation and manual pages
set (DOC_PATH "${RTLIB_TUTORIAL_PATH_DOCS}")
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/api-doc/html
DESTINATION ${MPIUNCERTAINTY_PATH_DOCS} OPTIONAL)
# install man pages into packages, scope is now project root..
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/api-doc/man/man3
DESTINATION ${MPIUNCERTAINTY_PATH_DOCS} OPTIONAL)
################################################################################
# Configuration resume
################################################################################
# display status message for important variables
message ( STATUS )
message ( STATUS "===================[ MpiUncertainty - Building System Configuration ]"
"====================" )
message ( STATUS "Version............... ${VERSION}" )
message ( STATUS "Build Flavor.......... ${BBQUE_BUILD_FLAVOR}" )
message ( STATUS " Target............. ${CONFIG_TARGET_NAME} ${CONFIG_TARGET_DESCRIPTION}" )
message ( STATUS " CFLAGS............. ${CMAKE_C_FLAGS}")
message ( STATUS " CXXFLAGS............. ${CMAKE_CXX_FLAGS}")
message ( STATUS "Installation prefix... ${CMAKE_INSTALL_PREFIX}" )
message ( STATUS " Binary............. <prefix>/${MPIUNCERTAINTY_PATH_BINS}" )
message ( STATUS " Recipes............ <prefix>/${MPIUNCERTAINTY_PATH_RECIPES}" )
message ( STATUS " Documentation...... <prefix>/${MPIUNCERTAINTY_PATH_DOCS}" )
message ( STATUS "Using RTLib........... ${BBQUE_RTLIB_LIBRARY}" )
message ( STATUS "Boost library......... ${Boost_LIBRARY_DIRS}" )
message ( STATUS )
message ( STATUS "Default values could be changes at command line, with:")
message ( STATUS " cmake -D<Variable>=<Value>" )
message ( STATUS "or use the '-i' cmake flag to run in interactive mode" )
message ( STATUS "======================================================"
"==========================" )
message(STATUS)