CMakeLists.txt 5.74 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 9 10 11 12
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)

#-----------------------------------------------------------------------------
# Slicer version number.
SET(Slicer3_VERSION_MAJOR "3")
SET(Slicer3_VERSION_MINOR "0")
SET(Slicer3_VERSION_PATCH "0")
SET(Slicer3_VERSION "${Slicer3_VERSION_MAJOR}.${Slicer3_VERSION_MINOR}")
SET(Slicer3_VERSION_FULL "${Slicer3_VERSION}.${Slicer3_VERSION_PATCH}")

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

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

#
# Top level slicer3 configurations
#

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

pieper's avatar
pieper committed
43 44 45

# Add the testing directories

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

54 55 56 57 58 59 60
#
# Libs
# - ITK
# - KWWidgets (pulls in VTK)
#

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

INCLUDE(${ITK_USE_FILE})


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

INCLUDE(${KWWidgets_USE_FILE})

barre's avatar
barre committed
77 78 79 80 81
# 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
82
KWWidgets_GENERATE_SETUP_PATHS_SCRIPTS(
barre's avatar
barre committed
83 84 85 86 87 88 89 90 91 92 93
  "${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)
94 95 96
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE("${VTK_CMAKE_DIR}/vtkWrapTcl.cmake")

97 98 99 100
#
## check versions of VTK to track CVS HEAD
#

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

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

#
# Subdirectories
#

SUBDIRS(
    Libs
    Base
    Modules
    Applications
)


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

131 132 133
# 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
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

# If the cmake version includes cpack, use it
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  IF(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
    INCLUDE(InstallRequiredSystemLibraries)
  ENDIF(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Medical Visualization and Processing Environment for Research")
  SET(CPACK_PACKAGE_VENDOR "NA-MIC")
  SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
  SET(CPACK_PACKAGE_VERSION_MAJOR "${Slicer3_VERSION_MAJOR}")
  SET(CPACK_PACKAGE_VERSION_MINOR "${Slicer3_VERSION_MINOR}")
  SET(CPACK_PACKAGE_VERSION_PATCH "${Slicer3_VERSION_PATCH}")
  SET(CPACK_INSTALL_CMAKE_PROJECTS
    "${Slicer3_BINARY_DIR};Slicer3;ALL;/")
  IF(EXISTS "${VTK_DIR}/CMakeCache.txt")
    SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${VTK_DIR};VTK;ALL;/")
  ENDIF(EXISTS "${VTK_DIR}/CMakeCache.txt")
  IF(EXISTS "${ITK_DIR}/CMakeCache.txt")
    SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ITK_DIR};ITK;ALL;/")
  ENDIF(EXISTS "${ITK_DIR}/CMakeCache.txt")
  IF(EXISTS "${KWWidgets_DIR}/CMakeCache.txt")
    SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${KWWidgets_DIR};KWWidgets;ALL;/")
  ENDIF(EXISTS "${KWWidgets_DIR}/CMakeCache.txt")

  SET(CPACK_PACKAGE_EXECUTABLES "Slicer3" "Slicer")
  INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")

andy's avatar
andy committed
162 163 164 165
OPTION(BUILD_DOCUMENTATION "Build Slicer3 Documentation" OFF)
IF(BUILD_DOCUMENTATION)
  SUBDIRS(Utilities/Doxygen)
ENDIF(BUILD_DOCUMENTATION)
andy's avatar
andy committed
166

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