CMakeLists.txt 6.45 KB
Newer Older
pieper's avatar
pieper committed
1
PROJECT( Slicer3 )
andy's avatar
andy committed
2
CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
3
4
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)

5
6
7
8
9
10
11
#
# Disable the warnings that DevStudio 2005 emits wrt to sprintf, strcpu, etc.
#
IF(CMAKE_COMPILER_2005)
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF(CMAKE_COMPILER_2005)

12
13
14
#-----------------------------------------------------------------------------
# Slicer version number.
SET(Slicer3_VERSION_MAJOR "3")
15
SET(Slicer3_VERSION_MINOR "0")
16
17
18
IF(NOT Slicer3_VERSION_PATCH)
  SET(Slicer3_VERSION_PATCH "0")
ENDIF(NOT Slicer3_VERSION_PATCH)
19
20
21
SET(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
SET(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")

22
23
24
25
#-----------------------------------------------------------------------------
# Build shared lib by default
OPTION(BUILD_SHARED_LIBS "Build Slicer3 with shared libraries." ON)

andy's avatar
andy committed
26
27
28
29
30
31
32
IF(BUILD_SHARED_LIBS)
  IF(WIN32 AND NOT UNIX)
    SET(SLICER3_LIB_INSTALL_DIR /bin)
  ELSE(WIN32 AND NOT UNIX)
    SET(SLICER3_LIB_INSTALL_DIR /lib)
  ENDIF(WIN32 AND NOT UNIX)
ENDIF(BUILD_SHARED_LIBS)
pieper's avatar
pieper committed
33
34
35
36
37

#
# Top level slicer3 configurations
#

38
SET (LIBRARY_OUTPUT_PATH ${Slicer3_BINARY_DIR}/bin/ 
pieper's avatar
pieper committed
39
40
41
42
43
44
45
        CACHE PATH 
        "Single output directory for building all libraries." 
        FORCE)
SET (EXECUTABLE_OUTPUT_PATH ${Slicer3_BINARY_DIR}/bin/ 
        CACHE PATH 
        "Single output directory for building all executables." 
        FORCE)
46
47
48
#
# Slicer libraries subdirectory
#
49
50
SET (SLICER_INSTALL_LIBRARIES_DIR "lib/Slicer3")
SET (SLICER_LIBRARIES_DIR "${Slicer3_BINARY_DIR}/${SLICER_INSTALL_LIBRARIES_DIR}")
51

pieper's avatar
pieper committed
52
53
54

# Add the testing directories

55
56
OPTION(BUILD_TESTING "Test the project" ON)
SET(Slicer3_BUILD_TESTING ${BUILD_TESTING})
pieper's avatar
pieper committed
57
58
IF(Slicer3_BUILD_TESTING)
    ENABLE_TESTING()
andy's avatar
andy committed
59
    INCLUDE (CTest)
60
    MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
pieper's avatar
pieper committed
61
62
ENDIF(Slicer3_BUILD_TESTING)

63
64
65
66
67
68
#
# Libs
# - ITK
# - KWWidgets (pulls in VTK)
#

69
70
71
72
73
74
75
## Python
OPTION(USE_PYTHON "Integrate a python interpreter into Slicer." OFF)
IF (USE_PYTHON)
   FIND_PACKAGE(PythonLibs)
ENDIF(USE_PYTHON)


76
## ITK
77
FIND_PACKAGE(ITK REQUIRED)
78
79
80
81
82
83
84
IF (NOT ITK_FOUND)
  MESSAGE (FATAL_ERROR "Need ITK to build")
ENDIF (NOT ITK_FOUND)

INCLUDE(${ITK_USE_FILE})


85
#
86
## KWWidgets
87
#
88
FIND_PACKAGE(KWWidgets REQUIRED)
89
90
91
92
93
94
IF (NOT KWWidgets_FOUND)
  MESSAGE (FATAL_ERROR "Need KWWidgets to build")
ENDIF (NOT KWWidgets_FOUND)

INCLUDE(${KWWidgets_USE_FILE})

95
96
97
98
99
100
101
102
103
#
# Teem
#
OPTION(USE_TEEM "Build Slicer3 with teem support." OFF)
IF(USE_TEEM)
  FIND_PACKAGE(TEEM REQUIRED)
  INCLUDE(${TEEM_USE_FILE})
ENDIF(USE_TEEM)

104

hliu's avatar
hliu committed
105
106
107
#
# OpenTracker 
#
108
109
OPTION(USE_OPENTRACKER "Build Slicer3 with OpenTracker support." OFF)

hliu's avatar
hliu committed
110
IF(USE_OPENTRACKER)
111
112
113
114
  # version of opentracker: 1.3 or 2.0
  # By default, use versin 1.3. If use 2.0, turn it off
  OPTION(OT_VERSION_13 "Specify the opentracker version." ON)

hliu's avatar
hliu committed
115
  FIND_LIBRARY(OPENTRACKER_LIB 
116
117
118
    NAMES opentrackerd opentracker OpenTracker NaviTrack
    PATHS "" 
  )
hliu's avatar
hliu committed
119
120
121
122
  IF(OPENTRACKER_LIB-NOTFOUND)
    MESSAGE (FATAL_ERROR "Need OpenTracker to build")
  ENDIF(OPENTRACKER_LIB-NOTFOUND)

123
124
125
126
127
128
129
130
131
132
133
  # include file for OpenTracker 1.3
  IF(OT_VERSION_13)
    SET(INC "OpenTracker.h")
  # include file for OpenTracker 2.0 
  ELSE(OT_VERSION_13)
    SET(INC "OpenTracker/OpenTracker.h") 
  ENDIF(OT_VERSION_13)
  FIND_PATH(OPENTRACKER_INC_DIR "${INC}" 
    ""
  )

hliu's avatar
hliu committed
134
135
136
137
138
139
140
141
142
  IF(OPENTRACKER_INC_DIR-NOTFOUND)
    MESSAGE (FATAL_ERROR "Need OpenTracker.h to build")
  ENDIF(OPENTRACKER_INC_DIR-NOTFOUND)
ELSE(USE_OPENTRACKER)
  SET(OPENTRACKER_LIB "")
  SET(OPENTRACKER_INC_DIR "")
ENDIF(USE_OPENTRACKER)


barre's avatar
barre committed
143
144
145
146
147
# Generate the default setup paths scripts.
# Generate some useful scripts that can be used to setup various environment 
# variables and launch the executable properly against external packages.

INCLUDE("${KWWidgets_CMAKE_DIR}/KWWidgetsPathsMacros.cmake")
barre's avatar
barre committed
148
KWWidgets_GENERATE_SETUP_PATHS_SCRIPTS(
149
150
  "${EXECUTABLE_OUTPUT_PATH}" "Slicer3SetupPaths" "${TEEM_DIR}/bin")
  
barre's avatar
barre committed
151
152
153
154
155
156
157
158
159
160

# VTK 5.0 does not have VTK_CMAKE_DIR
# Alternatively you could use KWWidget's wrapping, which encapsulate
# the differences between various VTK versions:
#  INCLUDE("${KWWidgets_CMAKE_DIR}/KWWidgetsWrappingMacros.cmake")
#  KWWidgets_WRAP_TCL(${LIB_NAME} LIB_TCL_SRCS "${LIB_SRCS}" "")

IF(NOT VTK_CMAKE_DIR)
  SET(VTK_CMAKE_DIR "${VTK_SOURCE_DIR}/CMake")
ENDIF(NOT VTK_CMAKE_DIR)
161
162
163
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")

164
165
166
167
#
## check versions of VTK to track CVS HEAD
#

168
169
170
171
172
173
174
175
176
177
178
179
FIND_PACKAGE(VTK REQUIRED)
IF(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
 INCLUDE(${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
ELSE(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
 MESSAGE("Using local version of VTKVersionMacros for compatibility.")
 INCLUDE(${Slicer3_SOURCE_DIR}/Scripts/VTKVersionMacros.cmake)
ENDIF(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)

VTK_GET_SOURCE_REVISION_AND_DATE(VTKsource_revision VTKsource_date)
IF(VTKsource_revision LESS 1.2196)
  MESSAGE(FATAL_ERROR "Sorry, your VTK library was last updated on ${VTKsource_date}. Its source revision, according to vtkKWWidgetsVersion.h, is ${VTKsource_revision}. Please update to a newer revision.")
ENDIF(VTKsource_revision LESS 1.2196) 
180

lorensen's avatar
lorensen committed
181
182
183
184
185
186
187
#
# These packages exist within the Slicer3 source tree
#
SET(GenerateCLP_DIR ${Slicer3_BINARY_DIR}/Libs/GenerateCLP)
SET(ModuleDescriptionParser_DIR ${Slicer3_BINARY_DIR}/Libs/ModuleDescriptionParser)
SET(vtkITK_DIR ${Slicer3_BINARY_DIR}/Libs/vtkITK)
SET(tclap_DIR ${Slicer3_BINARY_DIR}/Libs/tclap)
pieper's avatar
pieper committed
188

189

pieper's avatar
pieper committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#
# Subdirectories
#

SUBDIRS(
    Libs
    Base
    Modules
    Applications
)


IF (Slicer3_BUILD_TESTING)
    SUBDIRS( Testing )
ENDIF (Slicer3_BUILD_TESTING)

206
207
208
# include a test for endianness (used to be done by default)
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
andy's avatar
andy committed
209

210
211
212
# Launcher for slicer
SUBDIRS(Utilities/Launcher)

213
214
# Package slicer
SUBDIRS(Utilities/Package)
andy's avatar
andy committed
215

216
# Documentation
andy's avatar
andy committed
217
218
219
220
OPTION(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
IF(BUILD_DOCUMENTATION)
  SUBDIRS(Utilities/Doxygen)
ENDIF(BUILD_DOCUMENTATION)
andy's avatar
andy committed
221

222
# CMAke 2.4 does not have INSTALL(DIRECTORY ...) do it manually
hayes's avatar
hayes committed
223
#INSTALL(DIRECTORY "${Slicer3_BINARY_DIR}/Modules/Packages"
224
225
#  DESTINATION ${SLICER_INSTALL_LIBRARIES_DIR}/Modules)
INSTALL(CODE "EXECUTE_PROCESS\(COMMAND \"${CMAKE_COMMAND}\" -E copy_directory \"${SLICER_LIBRARIES_DIR}/Modules/Packages\" \"\${CMAKE_INSTALL_PREFIX}/${SLICER_INSTALL_LIBRARIES_DIR}/Modules/Packages\"\)")
226
227

CONFIGURE_FILE(
228
229
  ${Slicer3_SOURCE_DIR}/launch.tcl.in
  ${Slicer3_BINARY_DIR}/lib/launch.tcl
230
)
pieper's avatar
pieper committed
231
232

INSTALL(
pieper's avatar
pieper committed
233
  FILES ${Slicer3_BINARY_DIR}/lib/launch.tcl
pieper's avatar
pieper committed
234
235
  DESTINATION lib/launch.tcl
)