forked from DGtal-team/DGtal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
189 lines (159 loc) · 8.6 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# The name of our project is "DGtal". CMakeLists files in this
# project can refer to the root source directory of the project as
# ${DGTAL_SOURCE_DIR} and to the root binary directory of the
# project as ${DGTAL_BINARY_DIR}.
# -----------------------------------------------------------------------------
# Project definition
# -----------------------------------------------------------------------------
project (DGtal)
cmake_minimum_required (VERSION 2.6)
# -----------------------------------------------------------------------------
# Define variables and cmake parameters, and display some information
# -----------------------------------------------------------------------------
# Look for modules
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
SET(DGtal_VERSION_MAJOR 0)
SET(DGtal_VERSION_MINOR 4)
SET(DGtal_VERSION_PATCH "beta")
SET(DGTAL_VERSION "${DGtal_VERSION_MAJOR}.${DGtal_VERSION_MINOR}.${DGtal_VERSION_PATCH}")
SET(PROJECT_VERSION "${DGtal_VERSION_MAJOR}.${DGtal_VERSION_MINOR}.${DGtal_VERSION_PATCH}")
SET(VERSION ${DGtal_VERSION_MAJOR}.${DGtal_VERSION_MINOR}.${DGtal_VERSION_PATCH})
message(STATUS "-------------------------------------------------------------------------------")
MESSAGE(STATUS "DGtal Version ${PROJECT_VERSION}")
message(STATUS "-------------------------------------------------------------------------------" )
message(STATUS "Source DIR is ${PROJECT_SOURCE_DIR}")
message(STATUS "Binary DIR is ${PROJECT_BINARY_DIR}")
message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")
message(STATUS "Installation prefix directory is " ${CMAKE_INSTALL_PREFIX})
message(STATUS "Host system is " ${CMAKE_HOST_SYSTEM} " with processor " ${CMAKE_HOST_SYSTEM_PROCESSOR})
message(STATUS "Target system is " ${CMAKE_SYSTEM} " with processor " ${CMAKE_SYSTEM_PROCESSOR})
# -- Environement variables
if (UNIX)
add_definitions(-DUNIX)
endif (UNIX)
if (WIN32)
add_definitions(-DWIN32)
endif (WIN32)
if (APPLE)
add_definitions(-DAPPLE)
endif (APPLE)
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
set(INSTALL_DATA_DIR share CACHE PATH "Installation directory for data files")
# Make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE DATA)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
# -----------------------------------------------------------------------------
# Doxygen doc target
# -----------------------------------------------------------------------------
set(INSTALL_DOC_PATH ${CMAKE_INSTALL_PREFIX}/doc/${CMAKE_PROJECT_NAME} )
INCLUDE(${CMAKE_MODULE_PATH}/doxygen.cmake)
INCLUDE(${CMAKE_MODULE_PATH}/TargetDoxygenDoc.cmake OPTIONAL)
# -----------------------------------------------------------------------------
# uninstall target
# -----------------------------------------------------------------------------
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/TargetUninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TargetUninstall.cmake
@ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/TargetUninstall.cmake")
# -----------------------------------------------------------------------------
# Defines some variables
# -----------------------------------------------------------------------------
set ( LIBDGTAL_NAME "DGtal" )
set ( LIBDGTALVISU3D_NAME "DGtal-visu3d" )
# -----------------------------------------------------------------------------
# Parsing cmake options
# -----------------------------------------------------------------------------
OPTION(BUILD_SHARED_LIBS "Build shared libraries." ON)
OPTION(DEBUG_VERBOSE "Verbose messages in debug mode." OFF)
if ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
IF (DEBUG_VERBOSE)
ADD_DEFINITIONS(-DDEBUG_VERBOSE)
MESSAGE(STATUS "Debug verbose mode activated")
ENDIF(DEBUG_VERBOSE)
endif( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
# Functions are INLINE only in Release mode
if ( ${CMAKE_BUILD_TYPE} MATCHES "Release" )
ADD_DEFINITIONS(-DINLINE=inline)
else ( ${CMAKE_BUILD_TYPE} MATCHES "Release" )
ADD_DEFINITIONS(-DINLINE=)
endif ( ${CMAKE_BUILD_TYPE} MATCHES "Release" )
# -----------------------------------------------------------------------------
# Benchmark target
# -----------------------------------------------------------------------------
ADD_CUSTOM_TARGET(benchmark COMMAND echo "Benchmarks launched.....")
#------------------------------------------------------------------------------
# Configuration of the Config.h
#------------------------------------------------------------------------------
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/DGtal/base/Config.h.in
${PROJECT_SOURCE_DIR}/src/DGtal/base/Config.h)
#------------------------------------------------------------------------------
# Some directories and files should also be cleaned when invoking 'make clean'
#------------------------------------------------------------------------------
ADD_CUSTOM_TARGET(distclean
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/TargetDistclean.cmake")
#------------------------------------------------------------------------------
# CPack Configurations
#------------------------------------------------------------------------------
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
INCLUDE(${CMAKE_MODULE_PATH}/DGtalCPackConfig.cmake)
# -----------------------------------------------------------------------------
# Check CPP0X
# -----------------------------------------------------------------------------
INCLUDE(${CMAKE_MODULE_PATH}/CheckCPP0X.cmake)
# -----------------------------------------------------------------------------
# Check Mandatory Dependencies
# -----------------------------------------------------------------------------
INCLUDE(${CMAKE_MODULE_PATH}/CheckDGtalDependencies.cmake)
# -----------------------------------------------------------------------------
# Check Optional Dependencies
# -----------------------------------------------------------------------------
message(STATUS "-------------------------------------------------------------------------------")
message(STATUS "DGtal Library optional configuration:")
message(STATUS " (to change these values, use ccmake, a graphical")
message(STATUS " cmake frontend, or define cmake commandline variables")
message(STATUS " -e.g. '-DWITH_GMP:string=true'-, cf documentation)")
message(STATUS "-------------------------------------------------------------------------------")
INCLUDE(${CMAKE_MODULE_PATH}/CheckDGtalOptionalDependencies.cmake)
message(STATUS "-------------------------------------------------------------------------------")
# -----------------------------------------------------------------------------
# CTest options
# -----------------------------------------------------------------------------
ENABLE_TESTING()
include(CTest)
if (BUILD_TESTING)
if (CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall -pedantic -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage")
endif (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 -Wall -W -pedantic -fprofile-arcs -ftest-coverage")
endif (CMAKE_COMPILER_IS_GNUCC)
add_subdirectory (tests)
endif (BUILD_TESTING)
#------------------------------------------------------------------------------
# Add subdirectories
#------------------------------------------------------------------------------
add_subdirectory (src)
add_subdirectory (tools)
#------------------------------------------------------------------------------
# Examples
#------------------------------------------------------------------------------
OPTION(BUILD_EXAMPLES "Build examples." ON)
IF (BUILD_EXAMPLES)
add_subdirectory (examples)
ENDIF(BUILD_EXAMPLES)
#------------------------------------------------------------------------------
# DGtal Configuration file for the install target
#------------------------------------------------------------------------------
#--- Headers installation
install(DIRECTORY "${PROJECT_SOURCE_DIR}/src/"
DESTINATION "${INSTALL_INCLUDE_DIR}/" PATTERN "[A-Za-z0-9]+.*h")
INCLUDE(${CMAKE_MODULE_PATH}/DGtalConfigGenerator.cmake)