CMakeLists.txt 4.44 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
5
6
7
8
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)

#-----------------------------------------------------------------------------
# Slicer version number.
SET(Slicer3_VERSION_MAJOR "3")
SET(Slicer3_VERSION_MINOR "0")
9
10
11
IF(NOT Slicer3_VERSION_PATCH)
  SET(Slicer3_VERSION_PATCH "0")
ENDIF(NOT Slicer3_VERSION_PATCH)
12
13
14
SET(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
SET(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")

15
16
17
18
#-----------------------------------------------------------------------------
# Build shared lib by default
OPTION(BUILD_SHARED_LIBS "Build Slicer3 with shared libraries." ON)

andy's avatar
andy committed
19
20
21
22
23
24
25
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
26
27
28
29
30

#
# Top level slicer3 configurations
#

31
SET (LIBRARY_OUTPUT_PATH ${Slicer3_BINARY_DIR}/bin/ 
pieper's avatar
pieper committed
32
33
34
35
36
37
38
        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)
39
40
41
#
# Slicer libraries subdirectory
#
42
43
SET (SLICER_INSTALL_LIBRARIES_DIR "lib/Slicer3")
SET (SLICER_LIBRARIES_DIR "${Slicer3_BINARY_DIR}/${SLICER_INSTALL_LIBRARIES_DIR}")
44

pieper's avatar
pieper committed
45
46
47

# Add the testing directories

48
49
OPTION(BUILD_TESTING "Test the project" ON)
SET(Slicer3_BUILD_TESTING ${BUILD_TESTING})
pieper's avatar
pieper committed
50
51
IF(Slicer3_BUILD_TESTING)
    ENABLE_TESTING()
andy's avatar
andy committed
52
    INCLUDE (CTest)
53
    MARK_AS_ADVANCED(TCL_TCLSH DART_ROOT)
pieper's avatar
pieper committed
54
55
ENDIF(Slicer3_BUILD_TESTING)

56
57
58
59
60
61
62
#
# Libs
# - ITK
# - KWWidgets (pulls in VTK)
#

## ITK
63
FIND_PACKAGE(ITK REQUIRED)
64
65
66
67
68
69
70
71
IF (NOT ITK_FOUND)
  MESSAGE (FATAL_ERROR "Need ITK to build")
ENDIF (NOT ITK_FOUND)

INCLUDE(${ITK_USE_FILE})


## KWWidgets
72
FIND_PACKAGE(KWWidgets REQUIRED)
73
74
75
76
77
78
IF (NOT KWWidgets_FOUND)
  MESSAGE (FATAL_ERROR "Need KWWidgets to build")
ENDIF (NOT KWWidgets_FOUND)

INCLUDE(${KWWidgets_USE_FILE})

barre's avatar
barre committed
79
80
81
82
83
# 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
84
KWWidgets_GENERATE_SETUP_PATHS_SCRIPTS(
barre's avatar
barre committed
85
86
87
88
89
90
91
92
93
94
95
  "${EXECUTABLE_OUTPUT_PATH}" "Slicer3SetupPaths")

# 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)
96
97
98
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")

99
100
101
102
#
## check versions of VTK to track CVS HEAD
#

103
104
105
106
107
108
109
110
111
112
113
114
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) 
115

pieper's avatar
pieper committed
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

#
# Subdirectories
#

SUBDIRS(
    Libs
    Base
    Modules
    Applications
)


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

133
134
135
# 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
136

137
138
# Package slicer
SUBDIRS(Utilities/Package)
andy's avatar
andy committed
139

140
# Documentation
andy's avatar
andy committed
141
142
143
144
OPTION(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
IF(BUILD_DOCUMENTATION)
  SUBDIRS(Utilities/Doxygen)
ENDIF(BUILD_DOCUMENTATION)
andy's avatar
andy committed
145

146
# CMAke 2.4 does not have INSTALL(DIRECTORY ...) do it manually
hayes's avatar
hayes committed
147
#INSTALL(DIRECTORY "${Slicer3_BINARY_DIR}/Modules/Packages"
148
149
#  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\"\)")