-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
executable file
·329 lines (294 loc) · 10.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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#
# Minimum required version of CMAKE
#
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
#=================================================================================
#
# Print information about required/optional environment variables
#
MESSAGE(" ")
MESSAGE("REQUIRED environment variables for VTK:")
MESSAGE(" VTK_DIR - The directory containing the VTK include and lib directories")
MESSAGE(" ")
MESSAGE("OPTIONAL environment variables for MINC and NETCDF:")
MESSAGE(" MINC_DIR - The directory containing the MINC include and lib directories")
MESSAGE(" NETCDF_DIR - The directory containing the NETCDF include and lib directories")
MESSAGE(" ")
MESSAGE("OPTIONAL environment variables for QWT:")
MESSAGE(" QWT_DIR - The directory containing the QWT include and lib directories")
MESSAGE(" ")
MESSAGE("OPTIONAL environment varables for ZLIB but only needed if the ")
MESSAGE("the include files are not in a default include directory")
MESSAGE(" ZLIB_INC_DIR - The directory containing the ZLIB include files")
MESSAGE(" ZLIB_LIB_DIR - The directory containing the ZLIB library")
MESSAGE(" ")
MESSAGE("For Qt, the Qt program 'qmake' must be in the PATH")
MESSAGE(" ")
#=================================================================================
#
#
#
#message(INFORMATION "\nTo get the correct version of QT, qmake must be in the PATH\n")
#TSC: use "CACHE <type> <docstring>" syntax in SET commands so they can be overridden by cmake options
#=================================================================================
#
# Setting the compiler MUST be done before the PROJECT
# statement or else an infinite loop will occur indicating
# that the compiler has been redefined.
#
IF(APPLE)
ADD_DEFINITIONS(-DCARET_OS_MACOSX)
ELSEIF(UNIX)
ELSEIF(WIN32)
ADD_DEFINITIONS(-DCARET_OS_WINDOWS)
IF(MSVC)
ADD_DEFINITIONS(-DCARET_OS_WINDOWS_MSVC)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-D_USE_MATH_DEFINES -wd"4290" -wd"4244" -wd"4267" -wd"4305" -wd"4100" -wd"4005" -MP -DNOMINMAX)
ELSE()
ENDIF(CMAKE_CL_64)
ELSE(MSVC)
ENDIF(MSVC)
ELSE(APPLE)
MESSAGE(FATAL_ERROR "Unrecognized operating system " ${CMAKE_SYSTEM_NAME})
ENDIF(APPLE)
#cmake_policy(SET CMP0015 OLD)
#=================================================================================
#
# Shows compilation command when true
#
SET(CMAKE_VERBOSE_MAKEFILE TRUE CACHE BOOL "cause all build commands to be displayed")
#=================================================================================
#
# IF GNU compiler, functions without a return type or switch
# statements that do not handle all of the enumerated types
# are treated as an error. Also, all warnings.
#
IF (NOT MSVC)
if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
message("gcc major minor version numbers are: "${GCC_MAJOR},${GCC_MINOR})
endif()
if (CMAKE_COMPILER_IS_GNUCC)
if(${GCC_VERSION} VERSION_LESS "4.2")
ADD_DEFINITIONS(-W -Wall)
else()
ADD_DEFINITIONS(-W -Wall -Werror=return-type -Wunused-parameter)
endif()
endif()
ENDIF (NOT MSVC)
#=================================================================================
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ENDIF(OPENSSL_FOUND)
#=================================================================================
#
# Must have QT 4.7 or later
#
FIND_PACKAGE(Qt4 4.7.1 REQUIRED)
IF(QT4_FOUND)
ELSE(QT4_FOUND)
MESSAGE(FATAL_ERROR "QT4 not found")
ENDIF(QT4_FOUND)
#=================================================================================
#
# QT include files
#
INCLUDE(${QT_USE_FILE})
MESSAGE("QT Libraries: " ${QT_LIBRARIES})
#=================================================================================
SET (VTK_DIR $ENV{VTK_DIR})
FIND_PACKAGE(VTK REQUIRED)
IF (VTK_FOUND)
MESSAGE("VTK: " ${VTK_INCLUDE_DIRS})
MESSAGE("VTK: " ${VTK_LIBRARY_DIRS})
INCLUDE(${VTK_USE_FILE})
ELSE (VTK_FOUND)
MESSAGE(FATAL_ERROR "VTK not found, is environment variable VTK_DIR set?")
ENDIF(VTK_FOUND)
#=================================================================================
#
# Expect OpenMP on Apple and UNIX
#
#FIND_PACKAGE(OpenMP)
#IF (OPENMP_FOUND)
# ADD_DEFINITIONS(${OpenMP_CXX_FLAGS})
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
#ELSE (OPENMP_FOUND)
# MESSAGE(WARNING "OpenMP was not found")
#ENDIF(OPENMP_FOUND)
#=================================================================================
#
# Flags
#
ADD_DEFINITIONS( -DCARET_FLAG )
ADD_DEFINITIONS( -DHAVE_VTK )
ADD_DEFINITIONS( -DHAVE_VTK5 )
#=================================================================================
#
# ZLIB is optional
#
IF (EXISTS $ENV{ZLIB_DIR})
SET (ZLIB_ROOT $ENV{ZLIB_DIR})
ENDIF (EXISTS $ENV{ZLIB_DIR})
FIND_PACKAGE(ZLIB REQUIRED)
MESSAGE("ZLIB INCLUDE: " ${ZLIB_INCLUDE_DIRS})
MESSAGE("ZLIB LIB: " ${ZLIB_LIBRARIES})
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
#=================================================================================
#
# NETCDF is optional
#
SET(NETCDF_LIBRARIES "")
IF (EXISTS $ENV{NETCDF_DIR})
IF (EXISTS $ENV{MINC_DIR})
FIND_PATH(NETCDF_INCLUDE_DIRECTORY
netcdf.h
PATHS $ENV{NETCDF_DIR}/include)
MESSAGE("NETCDF INC: " ${NETCDF_INCLUDE_DIRECTORY})
IF (EXISTS ${NETCDF_INCLUDE_DIRECTORY})
INCLUDE_DIRECTORIES(${NETCDF_INCLUDE_DIRECTORY})
ELSE (EXISTS ${NETCDF_INCLUDE_DIRECTORY})
MESSAGE(FATAL_ERROR "Environment variable NETCDF_DIR is invalid path or not set")
ENDIF (EXISTS ${NETCDF_INCLUDE_DIRECTORY})
FIND_LIBRARY(NETCDF_LIBRARY
NAMES netcdf.lib libnetcdf.a libnetcdf.so netcdf.dll
PATHS $ENV{NETCDF_DIR}/lib)
MESSAGE("NETCDF LIB: " ${NETCDF_LIBRARY})
IF (EXISTS ${NETCDF_LIBRARY})
ELSE (EXISTS ${NETCDF_LIBRARY})
MESSAGE(FATAL_ERROR "Could not find NETCDF library")
ENDIF (EXISTS ${NETCDF_LIBRARY})
FIND_PATH(MINC_INCLUDE_DIRECTORY
minc.h
PATHS $ENV{MINC_DIR}/include)
MESSAGE("MINC INC: " ${MINC_INCLUDE_DIRECTORY})
IF (EXISTS ${MINC_INCLUDE_DIRECTORY})
INCLUDE_DIRECTORIES(${MINC_INCLUDE_DIRECTORY})
ELSE (EXISTS ${MINC_INCLUDE_DIRECTORY})
MESSAGE(FATAL_ERROR "Environment variable MINC_DIR is invalid path or not set")
ENDIF (EXISTS ${MINC_INCLUDE_DIRECTORY})
FIND_LIBRARY(MINC_LIBRARY
NAMES minc.lib libminc.a libminc.so minc.dll
minc2.lib libminc2.a libminc2.so minc2.dll
PATHS $ENV{MINC_DIR}/lib)
MESSAGE("MINC LIB: " ${MINC_LIBRARY})
IF (EXISTS ${MINC_LIBRARY})
ELSE (EXISTS ${MINC_LIBRARY})
MESSAGE(FATAL_ERROR "Could not find MINC library")
ENDIF (EXISTS ${MINC_LIBRARY})
MESSAGE("Configuring WITH MINC and NETCDF")
ADD_DEFINITIONS(-DHAVE_MINC)
ENDIF (EXISTS $ENV{MINC_DIR})
ENDIF (EXISTS $ENV{NETCDF_DIR})
#=================================================================================
#
# QWT is Optional
#
SET(QWT_LIBRARIES "")
IF (EXISTS $ENV{QWT_DIR})
FIND_PATH(QWT_INCLUDE_DIRECTORY
qwt.h
PATHS $ENV{QWT_DIR}/include)
MESSAGE("QWT INC: " ${QWT_INCLUDE_DIRECTORY})
IF (EXISTS ${QWT_INCLUDE_DIRECTORY})
ADD_DEFINITIONS(-DHAVE_QWT)
INCLUDE_DIRECTORIES(${QWT_INCLUDE_DIRECTORY})
ELSE (EXISTS ${QWT_INCLUDE_DIRECTORY})
MESSAGE(FATAL_ERROR "Environment variable QWT_INC_DIR is valid but QWT_INC_DIR is invalid path or not set")
ENDIF (EXISTS ${QWT_INCLUDE_DIRECTORY})
FIND_LIBRARY(QWT_LIBRARY
NAMES qwt.lib libqwt.a libqwt.so qwt.dll
PATHS $ENV{QWT_DIR}/lib)
MESSAGE("QWT LIB: " ${QWT_LIBRARY})
IF (EXISTS ${QWT_LIBRARY})
ELSE (EXISTS ${QWT_LIBRARY})
MESSAGE(FATAL_ERROR "Could not find QWT library")
ENDIF (EXISTS ${QWT_LIBRARY})
MESSAGE("Configuring WITH Qwt")
ELSE (EXISTS $ENV{QWT_DIR})
MESSAGE("Configuring WITHOUT Qwt")
ENDIF (EXISTS $ENV{QWT_DIR})
# IF (EXISTS $ENV{QWT_LIB_DIR})
# SET(QWT_LIBRARIES -L$ENV{QWT_LIB_DIR} -lqwt)
# ELSE (EXISTS $ENV{QWT_LIB_DIR})
# MESSAGE(FATAL_ERROR "Environment variable QWT_INC_DIR is valid but QWT_LIB_DIR is invalid path or not set")
# ENDIF (EXISTS $ENV{QWT_LIB_DIR})
#=================================================================================
#
# Need OpenGL
#
FIND_PACKAGE(OpenGL REQUIRED)
IF (OPENGL_FOUND)
#
# Need help finding includes on Apple
#
IF (APPLE)
# When searching for the include directory, find the location
# for the OpenGL framework rather than an individual header file.
FIND_PATH(OPENGL_INCLUDE_DIR OpenGL.framework
/System/Library/Frameworks
/Library/Frameworks
~/Library/Frameworks
)
ENDIF (APPLE)
#
# OpenGL Include Directory
#
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
MESSAGE("OPENGL include is " ${OPENGL_INCLUDE_DIR})
ELSE (OPENGL_FOUND)
MESSAGE(FATAL_ERROR "OpenGL Libraries were not found")
ENDIF (OPENGL_FOUND)
#=================================================================================
SET (VTK_LIBRARIES
-L${VTK_LIBRARY_DIRS}
vtkFiltering
vtkGenericFiltering
vtkImaging
vtkGraphics
vtkIO
vtkFiltering
vtkCommon
vtksys
vtkjpeg
vtkpng
vtkexpat
vtkzlib)
#SET (VTK_LIBRARIES
# -lvtkFiltering
# -lvtkGenericFiltering
# -lvtkImaging
# -lvtkGraphics
# -lvtkIO
# -lvtkFiltering
# -lvtkCommon
# -lvtksys
# -lvtkjpeg
# -lvtkpng
# -lvtkexpat
# -lvtkzlib)
#=================================================================================
#
# All subdirectories that will be configured for building
#
ADD_SUBDIRECTORY ( caret_common )
ADD_SUBDIRECTORY ( caret_vtk4_classes )
ADD_SUBDIRECTORY ( caret_uniformize )
ADD_SUBDIRECTORY ( caret_gifti )
ADD_SUBDIRECTORY ( caret_files )
ADD_SUBDIRECTORY ( caret_command_operations )
ADD_SUBDIRECTORY ( caret_brain_set )
ADD_SUBDIRECTORY ( caret_cifti )
ADD_SUBDIRECTORY ( caret_statistics )
ADD_SUBDIRECTORY ( caret_gui )
ADD_SUBDIRECTORY ( caret_widgets )
ADD_SUBDIRECTORY ( caret5 )
ADD_SUBDIRECTORY ( caret_command )
ADD_SUBDIRECTORY ( caret_edit )
ADD_SUBDIRECTORY ( wb_import )