-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
174 lines (147 loc) · 5.03 KB
/
CMakeLists.txt
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
##
# our functions and macros
##
# logging_level_to_define()
# Gives the define corresponding to a global logging level.
#
# For example: The logging level 'INFO' corresponds to the define 'logINFO'.
#
# Parameters:
# LOGGING_LEVEL STRING One of the logging levels:
# NO_LOGGING, ERROR, WARNING, INFO, DEBUG, DEBUG1, (...), DEBUG4
# input parameter
#
# DEFINE STRING output parameter
#
MACRO(LOGGING_LEVEL_TO_DEFINE LOGGING_LEVEL DEFINE)
IF(${LOGGING_LEVEL} STREQUAL "NO_LOGGING")
SET(${DEFINE} "psf::logNO_LOGGING")
ELSEIF(${LOGGING_LEVEL} STREQUAL "ERROR")
SET(${DEFINE} "psf::logERROR")
ELSEIF(${LOGGING_LEVEL} STREQUAL "WARNING")
SET(${DEFINE} "psf::logWARNING")
ELSEIF(${LOGGING_LEVEL} STREQUAL "INFO")
SET(${DEFINE} "psf::logINFO")
ELSEIF(${LOGGING_LEVEL} STREQUAL "DEBUG")
SET(${DEFINE} "psf::logDEBUG")
ELSEIF(${LOGGING_LEVEL} STREQUAL "DEBUG1")
SET(${DEFINE} "psf::logDEBUG1")
ELSEIF(${LOGGING_LEVEL} STREQUAL "DEBUG2")
SET(${DEFINE} "psf::logDEBUG2")
ELSEIF(${LOGGING_LEVEL} STREQUAL "DEBUG3")
SET(${DEFINE} "psf::logDEBUG3")
ELSEIF(${LOGGING_LEVEL} STREQUAL "DEBUG4")
SET(${DEFINE} "psf::logDEBUG4")
ELSE(${LOGGING_LEVEL} STREQUAL "NO_LOGGING")
MESSAGE(SEND_ERROR "Unknown LOGGING_LEVEL: ${LOGGING_LEVEL}. Default to INFO.")
SET(${DEFINE} "psf::logINFO")
ENDIF(${LOGGING_LEVEL} STREQUAL "NO_LOGGING")
ENDMACRO(LOGGING_LEVEL_TO_DEFINE)
##
# require CMake 2.6
##
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
##
# prerequisites
##
PROJECT(PSF)
# setup testing
ENABLE_TESTING()
INCLUDE(CTest)
# toggle normal/advanced parameters
MARK_AS_ADVANCED(CLEAR CMAKE_VERBOSE_MAKEFILE)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake
${PSF_BINARY_DIR}/include/psf/config.h
)
##
# build options
##
# logging level
SET(LOGGING_LEVEL "INFO" CACHE STRING "Choose a global logging level: NO_LOGGING, ERROR, WARNING, INFO, DEBUG, DEBUG1, ..., DEBUG4")
# vigra include
SET(VIGRA_INCLUDE "/usr/include/" CACHE STRING "Path to vigra include dir.")
# build static or shared libraries
OPTION(BUILD_SHARED_LIBS "Build psf and helper libraries in shared mode (else static)." ON)
### check host system type
# check for 64 bit OS
# Pointer has 8 bit on a 64Bit OS(only for intel&AMD)
IF( NOT APPLE )
IF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
SET(X86_64 FALSE)
ELSE( CMAKE_SIZEOF_VOID_P MATCHES 4 )
SET(X86_64 TRUE)
ENDIF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
ENDIF( NOT APPLE )
##
# cflags and compiler switches
##
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-DPSFDEBUG)
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DEXP_STL)
ELSE(MSVC)
ADD_DEFINITIONS(-Wall)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -D_FILE_OFFSET_BITS=64")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -D_FILE_OFFSET_BITS=64")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -Werror -ggdb3 -D_FILE_OFFSET_BITS=64")
IF(WITH_GCOV AND CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
ENDIF(WITH_GCOV AND CMAKE_BUILD_TYPE STREQUAL "Debug")
ENDIF(MSVC)
##
# global logging level
#
LOGGING_LEVEL_TO_DEFINE(LOGGING_LEVEL LOG_DEFINE)
ADD_DEFINITIONS(-D FILELOG_MAX_LEVEL=${LOG_DEFINE})
##
# 64-bit support
##
IF(X86_64)
ADD_DEFINITIONS(-DX86_64)
ENDIF(X86_64)
##
# includes paths
##
INCLUDE_DIRECTORIES(
${PSF_BINARY_DIR}
${PSF_BINARY_DIR}/include
${PSF_SOURCE_DIR}
${PSF_SOURCE_DIR}/src
${PSF_SOURCE_DIR}/include
${VIGRA_INCLUDE}
)
##
# directories to build
##
ADD_SUBDIRECTORY(src)
IF(BUILD_TESTING) # user option
ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTING)
##
# doxygen support
##
CONFIGURE_FILE(${PSF_SOURCE_DIR}/doc/Doxyfile.cmake
${PSF_BINARY_DIR}/doc/Doxyfile
@ONLY IMMEDIATE
)
FIND_PACKAGE(Doxygen)
ADD_CUSTOM_TARGET(doc COMMAND ${DOXYGEN} ${PSF_BINARY_DIR}/doc/Doxyfile)
##
# summary
##
MESSAGE(STATUS)
MESSAGE(STATUS "-----------------------------------------")
MESSAGE(STATUS "Running on: ${CMAKE_SYSTEM}")
MESSAGE(STATUS "Running on: ${CMAKE_SYSTEM_VERSION}")
MESSAGE(STATUS "This is a 64bit system: ${X86_64}")
MESSAGE(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
MESSAGE(STATUS "Global logging level: ${LOGGING_LEVEL}")
MESSAGE(STATUS "-----------------------------------------")
MESSAGE(STATUS)