#File Generated by Hans J. Johnson
#Please contact hans-johnson@uiowa.edu for making enhancments/corrections
PROJECT(NIFTI)
# Configure Dart testing support.
INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)

SUBDIRS(znzlib niftilib)
ADD_DEFINITIONS(-DHAVE_ZLIB)

# add option to build shared libraries. The default is OFF to maintain the
# current build behavior
OPTION ( BUILD_SHARED_LIBS "Toggle building shared libraries")

# Michael Hanke 2007-04-25 Note:
# 'Utilities' is merged into the include install path to be able to easily
# install into any other path if necessary. For the same reason lib, bin and
# include dir for standalone builds are only set if not yet defined.

###  USE AS PART OF ITK
IF("${ITK_VERSION_MAJOR}" GREATER 0.0)
#   MESSAGE(STATUS "---------------------ITK ZLIB  ${ITK_ZLIB_LIBRARIES}")
  ADD_DEFINITIONS(-DHAVE_ZLIB)
  ADD_DEFINITIONS(-DITKZLIB)
  SET(PACKAGE_PREFIX "ITK")
  SET(NIFTI_LIBRARY_PROPERTIES ${ITK_LIBRARY_PROPERTIES})
  SET(NIFTI_INSTALL_BIN_DIR "${ITK_INSTALL_BIN_DIR_CM24}")
  SET(NIFTI_INSTALL_LIB_DIR "${ITK_INSTALL_LIB_DIR_CM24}")
  SET(NIFTI_INSTALL_INCLUDE_DIR "${ITK_INSTALL_INCLUDE_DIR_CM24}/Utilities")
  SET(NIFTI_ZLIB_LIBRARIES ${ITK_ZLIB_LIBRARIES})
  SET(NIFTI_INSTALL_NO_DEVELOPMENT ${ITK_INSTALL_NO_DEVELOPMENT})
  SET(NIFTI_INSTALL_NO_LIBRARIES ${ITK_INSTALL_NO_LIBRARIES})

ELSE("${ITK_VERSION_MAJOR}" GREATER 0.0)
  SET(CPACK_PACKAGE_VERSION_MAJOR "2")
  SET(CPACK_PACKAGE_VERSION_MINOR "0")
  SET(CPACK_PACKAGE_VERSION_PATCH "0")
###  USE AS STAND ALONE PACKAGE
   FIND_PACKAGE(ZLIB)
#  MESSAGE(STATUS "---------------------SYSTEM ZLIB ${ZLIB_LIBRARY}")
  SET(PACKAGE_PREFIX "")
  # Set default shared library version
  # This library version will be applied to all libraries in the package
  # unless it is not explicitely for a certain lib.
  SET(NIFTI_SHAREDLIB_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
  STRING( REGEX MATCH "^[0-9]+" NIFTI_SHAREDLIB_SOVERSION ${NIFTI_SHAREDLIB_VERSION})
  SET(NIFTI_LIBRARY_PROPERTIES VERSION ${NIFTI_SHAREDLIB_VERSION} SOVERSION ${NIFTI_SHAREDLIB_SOVERSION})

  SET(NIFTI_INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
  SET(NIFTI_INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
  SET(NIFTI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/nifti")
  SET(NIFTI_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
  SET(NIFTI_INSTALL_NO_DEVELOPMENT 0)
  SET(NIFTI_INSTALL_NO_LIBRARIES 0)

  #Needs an if clause and more work before testing can take place.
  SUBDIRS(Testing)
  SUBDIRS(nifticdf utils)

  OPTION(USE_FSL_CODE "If OFF, The copyright of this code is questionable for inclusion with nifti." OFF)
  MARK_AS_ADVANCED(USE_FSL_CODE)

  # the order of subdirs is important! fsliolob has to preceed examples
  # as otherwise FSLIOLIB_SOURCE_DIR is undefined and hence the examples
  # will fail to compile
  IF(USE_FSL_CODE)
    SUBDIRS(fsliolib)
    SUBDIRS(examples)
  ENDIF(USE_FSL_CODE)
  ENABLE_TESTING()
  INCLUDE(Dart)

  ####################################
  ### Define information necessary for packaging with CPACK (http://www.cmake.org/Wiki/CMake:Packaging_With_CPack)
### The last section is concerned with installing the binaries and making distributions.
INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_NAME "NIFTI")

SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-dev")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Niftilib is a set of i/o libraries for reading and writing files in the nifti-1 data format. nifti-1 is a binary file format for storing medical image data, e.g. magnetic resonance image (MRI) and functional MRI (fMRI) brain images.")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${NIFTI_SOURCE_DIR}/README")
#SET(CPACK_RESOURCE_FILE_LICENSE "${NIFTI_SOURCE_DIR}/Copyright.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${NIFTI_SOURCE_DIR}/README")

SET(CPACK_PACKAGE_DEFAULT_LOCATION "/opt/${CPACK_PACKAGE_NAME}")
#SET(CPACK_PACKAGE_INSTALL_DIRECTORY "NIFTI ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${NIFTI}")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/")
SET(CPACK_SET_DESTDIR ON)

SET(CPACK_PACKAGE_VENDOR "NIFTI DFWG")

SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
#SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\.svn/;\\.swp$;\\.#;/#;\\.*~")
SET(CPACK_SOURCE_IGNORE_FILES "")
SET(CPACK_PACKAGE_EXECUTABLES "NIFTI";"A program for registering medical
images with mutual information.")

IF(WIN32 AND NOT UNIX)
  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  # There is a bug in NSI that does not handle full unix paths properly. Make
  # sure there is at least one set of four (4) backlasshes.
  SET(CPACK_PACKAGE_ICON
"${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} My Famous
Project")
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.nitrc.org")
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.nitrc.org")
  SET(CPACK_NSIS_CONTACT "xyz@domain.edu")
  SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
  SET(CPACK_STRIP_FILES OFF)
  SET(CPACK_SOURCE_STRIP_FILES OFF)
ENDIF(WIN32 AND NOT UNIX)

INCLUDE(CPack)


ENDIF("${ITK_VERSION_MAJOR}" GREATER 0.0)



IF(NOT DEFINED NIFTI_INSTALL_LIB_DIR)
  MESSAGE(FATAL_ERROR "Must set NIFTI_INSTALL_LIB_DIR.")
ENDIF(NOT DEFINED NIFTI_INSTALL_LIB_DIR)
IF(NOT DEFINED NIFTI_INSTALL_BIN_DIR)
  MESSAGE(FATAL_ERROR "Must set NIFTI_INSTALL_BIN_DIR.")
ENDIF(NOT DEFINED NIFTI_INSTALL_BIN_DIR)
IF(NOT DEFINED NIFTI_INSTALL_INCLUDE_DIR)
  MESSAGE(FATAL_ERROR "Must set NIFTI_INSTALL_INCLUDE_DIR.")
ENDIF(NOT DEFINED NIFTI_INSTALL_INCLUDE_DIR)







