<commit_before>PROJECT(MITK)

# only configure dart here if not already configured in the 
# parent directory
IF(NOT EXISTS ${PROJECT_BINARY_DIR}/../DartConfiguration.tcl)
INCLUDE(Dart)
ENDIF(NOT EXISTS ${PROJECT_BINARY_DIR}/../DartConfiguration.tcl)

INCLUDE(CMake/CoreHelpers.cmake)
INCLUDE(CMake/FunctionalityHelpers.cmake)
SET(KITNAME "MITK")
SET(LIBPOSTFIX "")
SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")

# MITK_VERSION
SET(MITK_VERSION_MAJOR "0")
SET(MITK_VERSION_MINOR "9")
SET(MITK_VERSION_PATCH "5")
SET(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")

IF(NOT MITK_KITNAME_FOR_MAINAPP)
SET(MITK_KITNAME_FOR_MAINAPP MITK)
ENDIF(NOT MITK_KITNAME_FOR_MAINAPP)
IF(NOT MITK_DIR)
SET(MITK_DIR ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(NOT MITK_DIR)


ADD_SUBDIRECTORY(Utilities) 

IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin)
  SET(ITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin")
ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin)

FIND_PACKAGE(ITK)
IF(${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH} STRLESS "3.4.0")
  MESSAGE(SEND_ERROR "ITK 3.4.0 or later required")
ENDIF(${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH} STRLESS "3.4.0")

INCLUDE(CMakeImportBuildSettings)
IF(ITK_BUILD_SETTINGS_FILE)
CMAKE_IMPORT_BUILD_SETTINGS(${ITK_BUILD_SETTINGS_FILE})
ENDIF(ITK_BUILD_SETTINGS_FILE)

# see bug #347: problems occur when mixing release/debug. So maybe a more specific check
# could be implemented to allow static ITK again.
IF(WIN32 AND ITK_BUILD_SHARED)
MESSAGE(SEND_ERROR "Using ITK shared libs on windows causes trouble. Please recompile ITK with BUILD_SHARED_LIBS OFF")
ENDIF(WIN32 AND ITK_BUILD_SHARED)

IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin)
  SET(VTK_DIR "${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin")
ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin)
FIND_PACKAGE(VTK)
APPLY_VTK_FLAGS()

IF(UNIX)
OPTION(BUILD_SHARED_LIBS "Build MITK with shared libraries." ON)
ELSE(UNIX)
OPTION(BUILD_SHARED_LIBS "Build MITK with shared libraries." OFF)
IF(BUILD_SHARED_LIBS)
  MESSAGE(FATAL_ERROR 
	  "Sorry. General BUILD_SHARED_LIBS is not available yet for MITK. Please look at MITK_BUILD_SHARED_CORE for creating dlls.")
ENDIF(BUILD_SHARED_LIBS)
ENDIF(UNIX)
OPTION(USE_ITKZLIB "Use the ITK zlib for pic compression." ON)
MARK_AS_ADVANCED(USE_ITKZLIB)

SET(CORE_DIRECTORIES DataStructures Algorithms IO Rendering Interactions Controllers)
OPTION(MITK_BUILD_SINGLE_CORE_LIB "Build all subdirectories of Core into single library, required for dlls on win32" ON)
MARK_AS_ADVANCED(MITK_BUILD_SINGLE_CORE_LIB)


FOREACH(d ${CORE_DIRECTORIES})
  SET(${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Core/${d})
  IF(NOT MITK_BUILD_SINGLE_CORE_LIB) 
  SET(${KITNAME}_CORE_LIBRARIES ${${KITNAME}_CORE_LIBRARIES} mitk${d})
  ENDIF(NOT MITK_BUILD_SINGLE_CORE_LIB)
ENDFOREACH(d)
IF(MITK_BUILD_SINGLE_CORE_LIB) 
  SET(${KITNAME}_CORE_LIBRARIES ${${KITNAME}_CORE_LIBRARIES} mitkCore)
ENDIF(MITK_BUILD_SINGLE_CORE_LIB)
SET(${KITNAME}_INCLUDE_DIRS ${PROJECT_BINARY_DIR} ${${KITNAME}_INCLUDE_DIRS} ${ITK_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS})

FOREACH(dir Core/DataStructures/mitkDataStorage Utilities Utilities/ipPic
Utilities/IIL4MITK Utilities/pic2vtk Utilities/tinyxml)
  SET(${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
ENDFOREACH(dir)
  

IF(WIN32)
  SET(${${KITNAME}_INCLUDE_DIRS} ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipPic/win32)
ENDIF(WIN32)

SET(${KITNAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/itkUNC ${${KITNAME}_INCLUDE_DIRS})
SET(MITK_LINK_DIRECTORIES ${LIBRARY_OUTPUT_PATH} ${ITK_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS})
LINK_DIRECTORIES(${MITK_LINK_DIRECTORIES})

IF(VTK_MAJOR_VERSION EQUAL 5)
    SET(VTK_FOR_MITK_LIBRARIES
      vtkGraphics vtkCommon vtkFiltering vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO vtkParallel vtkRendering vtkVolumeRendering vtkWidgets ${VTK_JPEG_LIBRARIES} ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_FREETYPE_LIBRARIES} QVTK
)
ELSE(VTK_MAJOR_VERSION EQUAL 5)
    SET(VTK_FOR_MITK_LIBRARIES
  vtkGraphics vtkCommon vtkFiltering vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO ${VTK_JPEG_LIBRARIES} vtkParallel vtkPatented ${VTK_PNG_LIBRARIES} vtkRendering ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} vtkfreetype
)
ENDIF(VTK_MAJOR_VERSION EQUAL 5)

SET(UTIL_FOR_MITK_LIBRARIES mitkIpPic mitkIpFunc)
SET(LIBRARIES_FOR_MITK_CORE
  ${LIBRARIES_FOR_${KITNAME}_CORE} ${UTIL_FOR_${KITNAME}_LIBRARIES} ${VTK_FOR_${KITNAME}_LIBRARIES} ${ITK_LIBRARIES}
)
 

SET(ANN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ann/include)
SET(IPSEGMENTATION_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipSegmentation)

ADD_SUBDIRECTORY(Core)

OPTION(BUILD_TESTING "Build the MITK tests." ON)
IF(BUILD_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(Testing)
ENDIF(BUILD_TESTING)

OPTION(USE_QT "Use Trolltech's Qt library" ON)

IF(USE_QT)
  SET(QT_MT_REQUIRED 1)
  # setting this to 3 since Qt4 support is in a very early stage of 
  # development. If you want to use Qt4, please create an initial cache with
  # a line  
  # DESIRED_QT_VERSION:STRING=4
  # 
  # or by passing -DDESIRED_QT_VERSION:STRING=4 as option to the very first
  # c(c)make call
  SET(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or     4")
  FIND_PACKAGE(Qt)
  IF(DESIRED_QT_VERSION EQUAL 3)
    SET(Q${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Qmitk ${PROJECT_BINARY_DIR}/Qmitk ${QT_INCLUDE_DIR})
    FOREACH(dir QmitkFunctionalityBase QmitkPropertyObservers QmitkApplicationBase QmitkFunctionalityComponents QmitkDialogBars) 
      SET(Q${KITNAME}_INCLUDE_DIRS ${Q${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Qmitk/${dir})<commit_msg>COMP (#1329): The Utilities directory has been moved in this file to the top, thus Qt-dependent targets in Utilities (openCherry) cannot see Qt specific CMake variables anymore. Hence moving the option USE_QT on top.<commit_after>PROJECT(MITK)

# only configure dart here if not already configured in the 
# parent directory
IF(NOT EXISTS ${PROJECT_BINARY_DIR}/../DartConfiguration.tcl)
INCLUDE(Dart)
ENDIF(NOT EXISTS ${PROJECT_BINARY_DIR}/../DartConfiguration.tcl)

INCLUDE(CMake/CoreHelpers.cmake)
INCLUDE(CMake/FunctionalityHelpers.cmake)
SET(KITNAME "MITK")
SET(LIBPOSTFIX "")
SET (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")

# MITK_VERSION
SET(MITK_VERSION_MAJOR "0")
SET(MITK_VERSION_MINOR "9")
SET(MITK_VERSION_PATCH "5")
SET(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")

IF(NOT MITK_KITNAME_FOR_MAINAPP)
SET(MITK_KITNAME_FOR_MAINAPP MITK)
ENDIF(NOT MITK_KITNAME_FOR_MAINAPP)
IF(NOT MITK_DIR)
SET(MITK_DIR ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(NOT MITK_DIR)

# some targets in Utilities also depend on Qt. Use this option
# to decide if they should be build
OPTION(USE_QT "Use Trolltech's Qt library" ON)

ADD_SUBDIRECTORY(Utilities) 

IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin)
  SET(ITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin")
ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/itk-bin)

FIND_PACKAGE(ITK)
IF(${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH} STRLESS "3.4.0")
  MESSAGE(SEND_ERROR "ITK 3.4.0 or later required")
ENDIF(${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH} STRLESS "3.4.0")

INCLUDE(CMakeImportBuildSettings)
IF(ITK_BUILD_SETTINGS_FILE)
CMAKE_IMPORT_BUILD_SETTINGS(${ITK_BUILD_SETTINGS_FILE})
ENDIF(ITK_BUILD_SETTINGS_FILE)

# see bug #347: problems occur when mixing release/debug. So maybe a more specific check
# could be implemented to allow static ITK again.
IF(WIN32 AND ITK_BUILD_SHARED)
MESSAGE(SEND_ERROR "Using ITK shared libs on windows causes trouble. Please recompile ITK with BUILD_SHARED_LIBS OFF")
ENDIF(WIN32 AND ITK_BUILD_SHARED)

IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin)
  SET(VTK_DIR "${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin")
ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/vtk-bin)
FIND_PACKAGE(VTK)
APPLY_VTK_FLAGS()

IF(UNIX)
OPTION(BUILD_SHARED_LIBS "Build MITK with shared libraries." ON)
ELSE(UNIX)
OPTION(BUILD_SHARED_LIBS "Build MITK with shared libraries." OFF)
IF(BUILD_SHARED_LIBS)
  MESSAGE(FATAL_ERROR 
	  "Sorry. General BUILD_SHARED_LIBS is not available yet for MITK. Please look at MITK_BUILD_SHARED_CORE for creating dlls.")
ENDIF(BUILD_SHARED_LIBS)
ENDIF(UNIX)
OPTION(USE_ITKZLIB "Use the ITK zlib for pic compression." ON)
MARK_AS_ADVANCED(USE_ITKZLIB)

SET(CORE_DIRECTORIES DataStructures Algorithms IO Rendering Interactions Controllers)
OPTION(MITK_BUILD_SINGLE_CORE_LIB "Build all subdirectories of Core into single library, required for dlls on win32" ON)
MARK_AS_ADVANCED(MITK_BUILD_SINGLE_CORE_LIB)


FOREACH(d ${CORE_DIRECTORIES})
  SET(${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Core/${d})
  IF(NOT MITK_BUILD_SINGLE_CORE_LIB) 
  SET(${KITNAME}_CORE_LIBRARIES ${${KITNAME}_CORE_LIBRARIES} mitk${d})
  ENDIF(NOT MITK_BUILD_SINGLE_CORE_LIB)
ENDFOREACH(d)
IF(MITK_BUILD_SINGLE_CORE_LIB) 
  SET(${KITNAME}_CORE_LIBRARIES ${${KITNAME}_CORE_LIBRARIES} mitkCore)
ENDIF(MITK_BUILD_SINGLE_CORE_LIB)
SET(${KITNAME}_INCLUDE_DIRS ${PROJECT_BINARY_DIR} ${${KITNAME}_INCLUDE_DIRS} ${ITK_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS})

FOREACH(dir Core/DataStructures/mitkDataStorage Utilities Utilities/ipPic
Utilities/IIL4MITK Utilities/pic2vtk Utilities/tinyxml)
  SET(${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
ENDFOREACH(dir)
  

IF(WIN32)
  SET(${${KITNAME}_INCLUDE_DIRS} ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipPic/win32)
ENDIF(WIN32)

SET(${KITNAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/itkUNC ${${KITNAME}_INCLUDE_DIRS})
SET(MITK_LINK_DIRECTORIES ${LIBRARY_OUTPUT_PATH} ${ITK_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS})
LINK_DIRECTORIES(${MITK_LINK_DIRECTORIES})

IF(VTK_MAJOR_VERSION EQUAL 5)
    SET(VTK_FOR_MITK_LIBRARIES
      vtkGraphics vtkCommon vtkFiltering vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO vtkParallel vtkRendering vtkVolumeRendering vtkWidgets ${VTK_JPEG_LIBRARIES} ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_FREETYPE_LIBRARIES} QVTK
)
ELSE(VTK_MAJOR_VERSION EQUAL 5)
    SET(VTK_FOR_MITK_LIBRARIES
  vtkGraphics vtkCommon vtkFiltering vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO ${VTK_JPEG_LIBRARIES} vtkParallel vtkPatented ${VTK_PNG_LIBRARIES} vtkRendering ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} vtkfreetype
)
ENDIF(VTK_MAJOR_VERSION EQUAL 5)

SET(UTIL_FOR_MITK_LIBRARIES mitkIpPic mitkIpFunc)
SET(LIBRARIES_FOR_MITK_CORE
  ${LIBRARIES_FOR_${KITNAME}_CORE} ${UTIL_FOR_${KITNAME}_LIBRARIES} ${VTK_FOR_${KITNAME}_LIBRARIES} ${ITK_LIBRARIES}
)
 

SET(ANN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ann/include)
SET(IPSEGMENTATION_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipSegmentation)

ADD_SUBDIRECTORY(Core)

OPTION(BUILD_TESTING "Build the MITK tests." ON)
IF(BUILD_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(Testing)
ENDIF(BUILD_TESTING)

IF(USE_QT)
  SET(QT_MT_REQUIRED 1)
  # setting this to 3 since Qt4 support is in a very early stage of 
  # development. If you want to use Qt4, please create an initial cache with
  # a line  
  # DESIRED_QT_VERSION:STRING=4
  # 
  # or by passing -DDESIRED_QT_VERSION:STRING=4 as option to the very first
  # c(c)make call
  SET(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or     4")
  FIND_PACKAGE(Qt)
  IF(DESIRED_QT_VERSION EQUAL 3)
    SET(Q${KITNAME}_INCLUDE_DIRS ${${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Qmitk ${PROJECT_BINARY_DIR}/Qmitk ${QT_INCLUDE_DIR})
    FOREACH(dir QmitkFunctionalityBase QmitkPropertyObservers QmitkApplicationBase QmitkFunctionalityComponents QmitkDialogBars) 
      SET(Q${KITNAME}_INCLUDE_DIRS ${Q${KITNAME}_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Qmitk/${dir})
{'fraction_non_alphanumeric': 0.09904101861552099, 'fraction_numerical': 0.007091627044886775, 'mean_word_length': 8.366037735849057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4282443', 'n_tokens_mistral': 5114, 'n_tokens_neox': 4862, 'n_words': 875}