<commit_before>project(ITKMINC)
set(ITKMINC_THIRD_PARTY 1)

# This depends on the external project, nothing locally built
set(ITKMINC_NO_SRC 1)

# For itk_minc2.h
set(ITKMINC_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/src)
if(ITK_USE_SYSTEM_MINC)

  find_package(LIBMINC REQUIRED)

  set(ITKMINC_SYSTEM_INCLUDE_DIRS
    ${LIBMINC_INCLUDE_DIRS}
    )

  set(ITKMINC_SYSTEM_LIBRARY_DIRS
    ${LIBMINC_LIBRARY_DIRS}
  )
  set(ITKMINC_LIBRARIES "${VOLUME_IO_LIBRARIES}" "${LIBMINC_LIBRARIES}")
  itk_module_impl()
else()
  set(MINC_EPNAME ITKMINC2_ExternalProject)
  set(lib_dir ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}-build)

  set(MINC_LIBRARY_PREFIX itk_)
  set(MINC_LIBRARY_NAME ${MINC_LIBRARY_PREFIX}minc2)
  set(ITKMINC_LIBRARIES "${MINC_LIBRARY_NAME}")

  set(ITKMINC_INCLUDE_DIRS
    ${ITKMINC_INCLUDE_DIRS}
    ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}
    ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}/volume_io/Include
    )

  if(NOT ITK_USE_SYSTEM_HDF5)
    set(ITKMINC_INCLUDE_DIRS ${ITKMINC_INCLUDE_DIRS}
        "${ITKHDF5_SOURCE_DIR}/src/itkhdf5"
        "${ITKHDF5_BINARY_DIR}/src/itkhdf5"
        )
  endif()

  set(MINC_CMAKE_ARGS )

  if(NOT WIN32)
    set(lib_prefix lib)
    set(lib_suffix "${CMAKE_STATIC_LIBRARY_SUFFIX}")
    set(lib_prefix "${CMAKE_STATIC_LIBRARY_PREFIX}")
  else()
    set(MINC_CMAKE_ARGS "-DCMAKE_CXX_FLAGS:STRING=-D_CRT_SECURE_NO_WARNINGS" "-DCMAKE_C_FLAGS:STRING=-D_CRT_SECURE_NO_WARNINGS")
    set(lib_prefix "")
    set(lib_suffix "${CMAKE_STATIC_LIBRARY_SUFFIX}")
    set(lib_prefix "${CMAKE_IMPORT_LIBRARY_PREFIX}")
  endif()

  # create imported targets when module is loaded from build tree
  if(CMAKE_CONFIGURATION_TYPES)
    set(ITKMINC_EXPORT_CODE_BUILD "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  foreach(c ${CMAKE_CONFIGURATION_TYPES})
    string(TOUPPER \"\${c}\" C)
    set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION_\${C}
      \"${lib_dir}/\${c}/${lib_prefix}\${MINC_LIBRARY_NAME}${lib_suffix}\")
  endforeach()
endif()
")
  else()
    set(ITKMINC_EXPORT_CODE_BUILD "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION
    \"${lib_dir}/${lib_prefix}${MINC_LIBRARY_NAME}${lib_suffix}\")
endif()
")
  endif()

  # create imported targets when module is loaded from install tree
  set(ITKMINC_EXPORT_CODE_INSTALL "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION
    \"\${ITK_INSTALL_PREFIX}/lib/${lib_prefix}${MINC_LIBRARY_NAME}${lib_suffix}\")
endif()
")

  itk_module_impl()

  foreach(libdep HDF5 ZLIB)
    #
    # if we're using ITK-built versions of libraries, then
    # have to find the actual library name, instead of the cmake logical name
    set(MINC${libdep}_LIBRARIES "")

    foreach(_lib ${ITK${libdep}_LIBRARIES})
      if(TARGET ${_lib})
        set(_lib $<TARGET_FILE:${_lib}>)
      endif()
      list(APPEND MINC${libdep}_LIBRARIES ${_lib})
    endforeach()

    # have to replace ; with another separator in order to pass lists into
    # the external project without them getting messed up.
    string(REPLACE ";" ":::" MINC${libdep}_LIBRARIES "${MINC${libdep}_LIBRARIES}")
    string(REPLACE ";" ":::" MINC${libdep}_INCLUDE_DIRS "${ITK${libdep}_INCLUDE_DIRS}")
  endforeach()

  set(MINC_GIT_REPOSITORY "https://github.com/BIC-MNI/libminc.git")
  set(MINC_GIT_TAG "c0b75f0403a4305c8995a3b8ed5c989a7d29a8d3")
  set(MINC_HDF5_ARGS )

  if(NOT ITK_USE_SYSTEM_HDF5)
    set(MINC_HDF5_ARGS  "-DHDF5_INCLUDE_DIR:PATH=${ITKHDF5_SOURCE_DIR}/src/itkhdf5:::${ITKHDF5_BINARY_DIR}/src")
    set(MINC_CMAKE_ARGS ${MINC_CMAKE_ARGS} "-DHDF5_LIBRARY:FILEPATH=${MINCHDF5_LIBRARIES}")
  endif()
  if(NOT ITK_USE_SYSTEM_ZLIB)
    set(MINC_CMAKE_ARGS ${MINC_CMAKE_ARGS} "-DZLIB_LIBRARY:FILEPATH=${MINCZLIB_LIBRARIES}")
  endif()

  itk_download_attempt_check(${MINC_EPNAME})
  ExternalProject_Add(${MINC_EPNAME}
    GIT_REPOSITORY ${MINC_GIT_REPOSITORY}
    GIT_TAG ${MINC_GIT_TAG}
#    URL ${CMAKE_CURRENT_SOURCE_DIR}/../../../../libminc
    SOURCE_DIR ${MINC_EPNAME}
    BINARY_DIR ${MINC_EPNAME}-build<commit_msg>BUG: updated libminc SHA to newest<commit_after>project(ITKMINC)
set(ITKMINC_THIRD_PARTY 1)

# This depends on the external project, nothing locally built
set(ITKMINC_NO_SRC 1)

# For itk_minc2.h
set(ITKMINC_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/src)
if(ITK_USE_SYSTEM_MINC)

  find_package(LIBMINC REQUIRED)

  set(ITKMINC_SYSTEM_INCLUDE_DIRS
    ${LIBMINC_INCLUDE_DIRS}
    )

  set(ITKMINC_SYSTEM_LIBRARY_DIRS
    ${LIBMINC_LIBRARY_DIRS}
  )
  set(ITKMINC_LIBRARIES "${VOLUME_IO_LIBRARIES}" "${LIBMINC_LIBRARIES}")
  itk_module_impl()
else()
  set(MINC_EPNAME ITKMINC2_ExternalProject)
  set(lib_dir ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}-build)

  set(MINC_LIBRARY_PREFIX itk_)
  set(MINC_LIBRARY_NAME ${MINC_LIBRARY_PREFIX}minc2)
  set(ITKMINC_LIBRARIES "${MINC_LIBRARY_NAME}")

  set(ITKMINC_INCLUDE_DIRS
    ${ITKMINC_INCLUDE_DIRS}
    ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}
    ${CMAKE_CURRENT_BINARY_DIR}/${MINC_EPNAME}/volume_io/Include
    )

  if(NOT ITK_USE_SYSTEM_HDF5)
    set(ITKMINC_INCLUDE_DIRS ${ITKMINC_INCLUDE_DIRS}
        "${ITKHDF5_SOURCE_DIR}/src/itkhdf5"
        "${ITKHDF5_BINARY_DIR}/src/itkhdf5"
        )
  endif()

  set(MINC_CMAKE_ARGS )

  if(NOT WIN32)
    set(lib_prefix lib)
    set(lib_suffix "${CMAKE_STATIC_LIBRARY_SUFFIX}")
    set(lib_prefix "${CMAKE_STATIC_LIBRARY_PREFIX}")
  else()
    set(MINC_CMAKE_ARGS "-DCMAKE_CXX_FLAGS:STRING=-D_CRT_SECURE_NO_WARNINGS" "-DCMAKE_C_FLAGS:STRING=-D_CRT_SECURE_NO_WARNINGS")
    set(lib_prefix "")
    set(lib_suffix "${CMAKE_STATIC_LIBRARY_SUFFIX}")
    set(lib_prefix "${CMAKE_IMPORT_LIBRARY_PREFIX}")
  endif()

  # create imported targets when module is loaded from build tree
  if(CMAKE_CONFIGURATION_TYPES)
    set(ITKMINC_EXPORT_CODE_BUILD "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  foreach(c ${CMAKE_CONFIGURATION_TYPES})
    string(TOUPPER \"\${c}\" C)
    set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION_\${C}
      \"${lib_dir}/\${c}/${lib_prefix}\${MINC_LIBRARY_NAME}${lib_suffix}\")
  endforeach()
endif()
")
  else()
    set(ITKMINC_EXPORT_CODE_BUILD "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION
    \"${lib_dir}/${lib_prefix}${MINC_LIBRARY_NAME}${lib_suffix}\")
endif()
")
  endif()

  # create imported targets when module is loaded from install tree
  set(ITKMINC_EXPORT_CODE_INSTALL "
if(NOT TARGET ${MINC_LIBRARY_NAME})
  add_library(${MINC_LIBRARY_NAME} ${_ITKMINC_LIB_LINKAGE} IMPORTED)
  set_property(TARGET ${MINC_LIBRARY_NAME} PROPERTY IMPORTED_LOCATION
    \"\${ITK_INSTALL_PREFIX}/lib/${lib_prefix}${MINC_LIBRARY_NAME}${lib_suffix}\")
endif()
")

  itk_module_impl()

  foreach(libdep HDF5 ZLIB)
    #
    # if we're using ITK-built versions of libraries, then
    # have to find the actual library name, instead of the cmake logical name
    set(MINC${libdep}_LIBRARIES "")

    foreach(_lib ${ITK${libdep}_LIBRARIES})
      if(TARGET ${_lib})
        set(_lib $<TARGET_FILE:${_lib}>)
      endif()
      list(APPEND MINC${libdep}_LIBRARIES ${_lib})
    endforeach()

    # have to replace ; with another separator in order to pass lists into
    # the external project without them getting messed up.
    string(REPLACE ";" ":::" MINC${libdep}_LIBRARIES "${MINC${libdep}_LIBRARIES}")
    string(REPLACE ";" ":::" MINC${libdep}_INCLUDE_DIRS "${ITK${libdep}_INCLUDE_DIRS}")
  endforeach()

  set(MINC_GIT_REPOSITORY "https://github.com/BIC-MNI/libminc.git")
  set(MINC_GIT_TAG "3cead8905192f7f68e1a4c82144df3750a7e2b4e")
  set(MINC_HDF5_ARGS )

  if(NOT ITK_USE_SYSTEM_HDF5)
    set(MINC_HDF5_ARGS  "-DHDF5_INCLUDE_DIR:PATH=${ITKHDF5_SOURCE_DIR}/src/itkhdf5:::${ITKHDF5_BINARY_DIR}/src")
    set(MINC_CMAKE_ARGS ${MINC_CMAKE_ARGS} "-DHDF5_LIBRARY:FILEPATH=${MINCHDF5_LIBRARIES}")
  endif()
  if(NOT ITK_USE_SYSTEM_ZLIB)
    set(MINC_CMAKE_ARGS ${MINC_CMAKE_ARGS} "-DZLIB_LIBRARY:FILEPATH=${MINCZLIB_LIBRARIES}")
  endif()

  itk_download_attempt_check(${MINC_EPNAME})
  ExternalProject_Add(${MINC_EPNAME}
    GIT_REPOSITORY ${MINC_GIT_REPOSITORY}
    GIT_TAG ${MINC_GIT_TAG}
#    URL ${CMAKE_CURRENT_SOURCE_DIR}/../../../../libminc
    SOURCE_DIR ${MINC_EPNAME}
    BINARY_DIR ${MINC_EPNAME}-build
{'fraction_non_alphanumeric': 0.12622931852366076, 'fraction_numerical': 0.010991553858613907, 'mean_word_length': 5.711180124223603, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5510465', 'n_tokens_mistral': 3749, 'n_tokens_neox': 3508, 'n_words': 470}