CMakeLists.txt 7.96 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 15 16 17 18 19 20 21
#
# avoid linker bug in Mac OS 10.5
# see:
# http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
#
IF(APPLE)
  SET (CMAKE_SHARED_LINKER_FLAGS "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
  SET (CMAKE_EXE_LINKER_FLAGS "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
ENDIF(APPLE)

22 23 24
#-----------------------------------------------------------------------------
# Slicer version number.
SET(Slicer3_VERSION_MAJOR "3")
25
SET(Slicer3_VERSION_MINOR "0")
26 27 28
IF(NOT Slicer3_VERSION_PATCH)
  SET(Slicer3_VERSION_PATCH "0")
ENDIF(NOT Slicer3_VERSION_PATCH)
29 30 31
SET(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
SET(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")

32 33 34 35
#-----------------------------------------------------------------------------
# Build shared lib by default
OPTION(BUILD_SHARED_LIBS "Build Slicer3 with shared libraries." ON)

andy's avatar
andy committed
36 37 38 39 40 41 42
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
43 44 45 46 47

#
# Top level slicer3 configurations
#

48
SET (LIBRARY_OUTPUT_PATH ${Slicer3_BINARY_DIR}/bin/ 
pieper's avatar
pieper committed
49 50 51 52
        CACHE PATH 
        "Single output directory for building all libraries." 
        FORCE)
SET (EXECUTABLE_OUTPUT_PATH ${Slicer3_BINARY_DIR}/bin/ 
hliu's avatar
hliu committed
53

pieper's avatar
pieper committed
54 55 56
        CACHE PATH 
        "Single output directory for building all executables." 
        FORCE)
57 58 59
#
# Slicer libraries subdirectory
#
60
SET (SLICER_INSTALL_LIBRARIES_DIR "lib/Slicer3")
hliu's avatar
hliu committed
61

62
SET (SLICER_LIBRARIES_DIR "${Slicer3_BINARY_DIR}/${SLICER_INSTALL_LIBRARIES_DIR}")
63

pieper's avatar
pieper committed
64 65 66

# Add the testing directories

67 68
OPTION(BUILD_TESTING "Test the project" ON)
SET(Slicer3_BUILD_TESTING ${BUILD_TESTING})
pieper's avatar
pieper committed
69 70
IF(Slicer3_BUILD_TESTING)
    ENABLE_TESTING()
andy's avatar
andy committed
71
    INCLUDE (CTest)
72
    MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
pieper's avatar
pieper committed
73 74
ENDIF(Slicer3_BUILD_TESTING)

hliu's avatar
hliu committed
75

76 77 78 79 80 81
#
# Libs
# - ITK
# - KWWidgets (pulls in VTK)
#

82 83 84 85
## Python
OPTION(USE_PYTHON "Integrate a python interpreter into Slicer." OFF)
IF (USE_PYTHON)
   FIND_PACKAGE(PythonLibs)
86
   ADD_DEFINITIONS(-DUSE_PYTHON)
87 88 89
ENDIF(USE_PYTHON)


90
## ITK
91
FIND_PACKAGE(ITK REQUIRED)
92 93 94 95
IF (NOT ITK_FOUND)
  MESSAGE (FATAL_ERROR "Need ITK to build")
ENDIF (NOT ITK_FOUND)

hliu's avatar
hliu committed
96

97 98 99
INCLUDE(${ITK_USE_FILE})


100
#
101
## KWWidgets
102
#
103
FIND_PACKAGE(KWWidgets REQUIRED)
104 105 106 107
IF (NOT KWWidgets_FOUND)
  MESSAGE (FATAL_ERROR "Need KWWidgets to build")
ENDIF (NOT KWWidgets_FOUND)

hliu's avatar
hliu committed
108

109 110
INCLUDE(${KWWidgets_USE_FILE})

111 112 113
#
# Teem
#
114 115 116 117 118
FIND_PACKAGE(TEEM REQUIRED)
IF (NOT TEEM_FOUND)
  MESSAGE (FATAL_ERROR "Need TEEMK to build")
ENDIF (NOT TEEM_FOUND)
INCLUDE(${TEEM_USE_FILE})
119

120

121 122 123
#
# BatchMake
#
124
OPTION(USE_BatchMake "Build Slicer3 with BatchMake support." OFF)
125 126 127 128 129 130 131 132
IF(USE_BatchMake)
  FIND_PACKAGE(BatchMake REQUIRED)
  INCLUDE(${BatchMake_USE_FILE})
ENDIF(USE_BatchMake)

#
# MIDAS
#
133
OPTION(USE_MIDAS "Build Slicer3 with MIDAS support." OFF)
134 135


hliu's avatar
hliu committed
136
#
137
# NaviTrack 
hliu's avatar
hliu committed
138
#
139
OPTION(USE_NAVITRACK "Build Slicer3 with NaviTrack support." OFF)
140
IF(USE_NAVITRACK)
141

142 143
  FIND_LIBRARY(NAVITRACK_LIB 
    NAMES NaviTrack
144
    PATHS ${NAVITRACK_LIB_DIR} 
145
  )
146 147 148
  IF(NAVITRACK_LIB-NOTFOUND)
    MESSAGE (FATAL_ERROR "Need NaviTrack to build")
  ENDIF(NAVITRACK_LIB-NOTFOUND)
hliu's avatar
hliu committed
149

150
  # include file for OpenTracker 2.0 
151 152
  FIND_PATH(NAVITRACK_INC "OpenTracker/OpenTracker.h" 
    ${NAVITRACK_INC_DIR}
153 154
  )

155
  IF(NAVITRACK_INC-NOTFOUND)
hliu's avatar
hliu committed
156
    MESSAGE (FATAL_ERROR "Need OpenTracker.h to build")
157 158 159 160 161
  ENDIF(NAVITRACK_INC-NOTFOUND)
ELSE(USE_NAVITRACK)
  SET(NAVITRACK_LIB "")
  SET(NAVITRACK_INC "")
ENDIF(USE_NAVITRACK)
hliu's avatar
hliu committed
162 163


hliu's avatar
hliu committed
164 165 166 167
#
# IGSTK
# Built in Slicer3-lib
#
168
OPTION(USE_IGSTK "Build Slicer3 with IGSTK support." OFF)
hliu's avatar
hliu committed
169 170 171 172 173 174
IF(USE_IGSTK)
  FIND_PACKAGE(IGSTK REQUIRED)
  INCLUDE(${IGSTK_USE_FILE})
ENDIF(USE_IGSTK)


barre's avatar
barre committed
175 176 177 178 179
# 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
180
KWWidgets_GENERATE_SETUP_PATHS_SCRIPTS(
181 182
  "${EXECUTABLE_OUTPUT_PATH}" "Slicer3SetupPaths" "${TEEM_DIR}/bin"
  "${BatchMake_DIR}/bin")
183
  
barre's avatar
barre committed
184 185

# VTK 5.0 does not have VTK_CMAKE_DIR
hliu's avatar
hliu committed
186

barre's avatar
barre committed
187 188 189 190 191 192 193 194
# 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)
195 196 197
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")

198 199 200 201
#
## check versions of VTK to track CVS HEAD
#

202 203 204 205
FIND_PACKAGE(VTK REQUIRED)
IF(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
 INCLUDE(${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
ELSE(EXISTS ${VTK_CMAKE_DIR}/VTKVersionMacros.cmake)
206
 #MESSAGE("Using local version of VTKVersionMacros for compatibility.")
207 208 209 210 211 212 213
 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) 
214

lorensen's avatar
lorensen committed
215 216 217 218 219 220
#
# 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)
221
SET(TCLAP_DIR ${Slicer3_BINARY_DIR}/Libs/tclap)
pieper's avatar
pieper committed
222

223

pieper's avatar
pieper committed
224 225 226 227
#
# Subdirectories
#

228 229 230 231 232 233
OPTION(BUILD_CLI "Build Slicer3 CLI Plugins" ON)
MARK_AS_ADVANCED(BUILD_CLI)

OPTION(BUILD_MODULES "Build Slicer3 Modules" ON)
MARK_AS_ADVANCED(BUILD_MODULES)

pieper's avatar
pieper committed
234
SUBDIRS(
235 236 237 238
  Libs
  Base
  Applications
  )
pieper's avatar
pieper committed
239

240 241 242
IF(BUILD_MODULES)
  SUBDIRS(Modules)
ENDIF(BUILD_MODULES)
pieper's avatar
pieper committed
243 244 245 246 247

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

248 249 250
# 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
251

252 253 254
# Launcher for slicer
SUBDIRS(Utilities/Launcher)

255 256
# Package slicer
SUBDIRS(Utilities/Package)
andy's avatar
andy committed
257

258
# Documentation
andy's avatar
andy committed
259 260 261 262
OPTION(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
IF(BUILD_DOCUMENTATION)
  SUBDIRS(Utilities/Doxygen)
ENDIF(BUILD_DOCUMENTATION)
andy's avatar
andy committed
263

264
# CMAke 2.4 does not have INSTALL(DIRECTORY ...) do it manually
hayes's avatar
hayes committed
265
#INSTALL(DIRECTORY "${Slicer3_BINARY_DIR}/Modules/Packages"
266 267
#  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\"\)")
268 269

CONFIGURE_FILE(
270 271
  ${Slicer3_SOURCE_DIR}/launch.tcl.in
  ${Slicer3_BINARY_DIR}/lib/launch.tcl
272
)
pieper's avatar
pieper committed
273 274

INSTALL(
pieper's avatar
pieper committed
275
  FILES ${Slicer3_BINARY_DIR}/lib/launch.tcl
276
  DESTINATION lib
pieper's avatar
pieper committed
277
)
278

279 280 281
# setup file for setting custom ctest vars
CONFIGURE_FILE(${Slicer3_SOURCE_DIR}/CTestCustom.cmake.in
  ${Slicer3_BINARY_DIR}/CTestCustom.cmake @ONLY)
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297

# Set up for building against a Slicer3 build tree and a Slicer3 installation 
#
#
INCLUDE( ${Slicer3_SOURCE_DIR}/GenerateSlicer3Config.cmake)

CONFIGURE_FILE(${Slicer3_SOURCE_DIR}/UseSlicer3.cmake.in
               ${Slicer3_BINARY_DIR}/UseSlicer3.cmake COPYONLY IMMEDIATE)

INSTALL(FILES
#   ${Slicer3_BINARY_DIR}/Slicer3BuildSettings.cmake
   ${Slicer3_BINARY_DIR}/UseSlicer3.cmake
   ${Slicer3_BINARY_DIR}/Utilities/Slicer3Config.cmake
   DESTINATION lib
   COMPONENT Development
)