<commit_before>project(CTKDICOMCore)

#
# See CTK/CMake/ctkMacroBuildLib.cmake for details
#

set(KIT_export_directive "CTK_DICOM_CORE_EXPORT")

# determine the DCMTK version we're using
if(EXISTS ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
  set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
elseif(EXISTS ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
  set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
else()
  message(SEND_ERROR "DCMTK version cannot be determined!")
endif()

file(READ ${_DCMTK_CONFIG_HEADER} _DCMTK_CONFIG)
# simple check, we do not expect anything else
if(_DCMTK_CONFIG MATCHES "PACKAGE_VERSION_NUMBER 360")
  set(DCMTK_VERSION_IS_360 1)
  message(STATUS "Detected DCMTK 3.6.0, will include backported SCU")
endif()

# Source files
set(KIT_SRCS
  ctkDICOMAbstractThumbnailGenerator.cpp
  ctkDICOMAbstractThumbnailGenerator.h
  ctkDICOMDatabase.cpp
  ctkDICOMDatabase.h
  ctkDICOMItem.h
  ctkDICOMFilterProxyModel.cpp
  ctkDICOMFilterProxyModel.h
  ctkDICOMIndexer.cpp
  ctkDICOMIndexer.h
  ctkDICOMIndexer_p.h
  ctkDICOMItem.cpp
  ctkDICOMItem.h
  ctkDICOMModel.cpp
  ctkDICOMModel.h
  ctkDICOMObjectModel.cpp
  ctkDICOMObjectModel.h
  ctkDICOMPersonName.cpp
  ctkDICOMPersonName.h
  ctkDICOMQuery.cpp
  ctkDICOMQuery.h
  ctkDICOMRetrieve.cpp
  ctkDICOMRetrieve.h
  ctkDICOMTester.cpp
  ctkDICOMTester.h
  ctkDICOMUtil.cpp
  ctkDICOMUtil.h
)

if(DCMTK_VERSION_IS_360)
  list(APPEND KIT_SRCS ctkDcmSCU.cc)
endif(DCMTK_VERSION_IS_360)


# Abstract class should not be wrapped !
set_source_files_properties(
  ctkDICOMAbstractThumbnailGenerator.h
  WRAP_EXCLUDE
  )

# Check if DCMTK provides 'dcmtk::log4cplus::Logger', if not fallback to 'log4cplus::Logger'.
# Indeed, following DCMTK-3.6.1_20110519 (commit e39d190), log4cplus has been moved
# into dcmtk::log4cplus namespace.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS -DHAVE_CONFIG_H)
set(CMAKE_REQUIRED_INCLUDES ${DCMTK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${DCMTK_LIBRARIES})
check_cxx_source_compiles(
  "#include <dcmtk/oflog/oflog.h>\nint main(int, char*[]){dcmtk::log4cplus::Logger logger; return 0;}"
  HAVE_DCMTK_LOG4CPLUS_LOGGER)
if(HAVE_DCMTK_LOG4CPLUS_LOGGER)
  set_source_files_properties(
    ctkDICOMUtil.cpp
    PROPERTIES COMPILE_DEFINITIONS HAVE_DCMTK_LOG4CPLUS_LOGGER
    )
endif()

# Headers that should run through moc
set(KIT_MOC_SRCS
  ctkDICOMAbstractThumbnailGenerator.h
  ctkDICOMDatabase.h<commit_msg>Fix HAVE_DCMTK_LOG4CPLUS_LOGGER test on multi-configuration build system.<commit_after>project(CTKDICOMCore)

#
# See CTK/CMake/ctkMacroBuildLib.cmake for details
#

set(KIT_export_directive "CTK_DICOM_CORE_EXPORT")

# determine the DCMTK version we're using
if(EXISTS ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
  set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/cfunix.h)
elseif(EXISTS ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
  set(_DCMTK_CONFIG_HEADER ${DCMTK_config_INCLUDE_DIR}/osconfig.h)
else()
  message(SEND_ERROR "DCMTK version cannot be determined!")
endif()

file(READ ${_DCMTK_CONFIG_HEADER} _DCMTK_CONFIG)
# simple check, we do not expect anything else
if(_DCMTK_CONFIG MATCHES "PACKAGE_VERSION_NUMBER 360")
  set(DCMTK_VERSION_IS_360 1)
  message(STATUS "Detected DCMTK 3.6.0, will include backported SCU")
endif()

# Source files
set(KIT_SRCS
  ctkDICOMAbstractThumbnailGenerator.cpp
  ctkDICOMAbstractThumbnailGenerator.h
  ctkDICOMDatabase.cpp
  ctkDICOMDatabase.h
  ctkDICOMItem.h
  ctkDICOMFilterProxyModel.cpp
  ctkDICOMFilterProxyModel.h
  ctkDICOMIndexer.cpp
  ctkDICOMIndexer.h
  ctkDICOMIndexer_p.h
  ctkDICOMItem.cpp
  ctkDICOMItem.h
  ctkDICOMModel.cpp
  ctkDICOMModel.h
  ctkDICOMObjectModel.cpp
  ctkDICOMObjectModel.h
  ctkDICOMPersonName.cpp
  ctkDICOMPersonName.h
  ctkDICOMQuery.cpp
  ctkDICOMQuery.h
  ctkDICOMRetrieve.cpp
  ctkDICOMRetrieve.h
  ctkDICOMTester.cpp
  ctkDICOMTester.h
  ctkDICOMUtil.cpp
  ctkDICOMUtil.h
)

if(DCMTK_VERSION_IS_360)
  list(APPEND KIT_SRCS ctkDcmSCU.cc)
endif(DCMTK_VERSION_IS_360)


# Abstract class should not be wrapped !
set_source_files_properties(
  ctkDICOMAbstractThumbnailGenerator.h
  WRAP_EXCLUDE
  )

# XXX DCMTK 3.6.1: Remove the HAVE_DCMTK_LOG4CPLUS_LOGGER test when DCMTK 3.6.1
#     can be expected on all supported platforms.
# XXX On multi configuration system, there is no way to run 'try_compile` configure
#     tests based on the configuration that WILL be selected to build the project.
#     Since the try compile test 'HAVE_DCMTK_LOG4CPLUS_LOGGER' has originally been
#     added to be able to build against DCMTK 3.6.0 available by default on linux
#     distribution. Let's skip it in the case of multi configuration system and
#     assume DCMTK provides 'dcmtk::log4cplus::Logger'.
# TODO When build as external project, the config of the parent project could be passed to CTK
#      and used as a hint. We need to define what would be the convention for such hint.
if(CMAKE_CONFIGURATION_TYPES AND NOT DEFINED HAVE_DCMTK_LOG4CPLUS_LOGGER)
  set(HAVE_DCMTK_LOG4CPLUS_LOGGER 1 CACHE INTERNAL "Test HAVE_DCMTK_LOG4CPLUS_LOGGER")
endif()
# Check if DCMTK provides 'dcmtk::log4cplus::Logger', if not fallback to 'log4cplus::Logger'.
# Indeed, following DCMTK-3.6.1_20110519 (commit e39d190), log4cplus has been moved
# into dcmtk::log4cplus namespace.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS -DHAVE_CONFIG_H)
set(CMAKE_REQUIRED_INCLUDES ${DCMTK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${DCMTK_LIBRARIES})
check_cxx_source_compiles(
  "#include <dcmtk/oflog/oflog.h>\nint main(int, char*[]){dcmtk::log4cplus::Logger logger; return 0;}"
  HAVE_DCMTK_LOG4CPLUS_LOGGER)
if(HAVE_DCMTK_LOG4CPLUS_LOGGER)
  set_source_files_properties(
    ctkDICOMUtil.cpp
    PROPERTIES COMPILE_DEFINITIONS HAVE_DCMTK_LOG4CPLUS_LOGGER
    )
endif()

# Headers that should run through moc
set(KIT_MOC_SRCS
  ctkDICOMAbstractThumbnailGenerator.h
  ctkDICOMDatabase.h
{'fraction_non_alphanumeric': 0.07318312722344571, 'fraction_numerical': 0.016771133322039642, 'mean_word_length': 6.079136690647482, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3284491', 'n_tokens_mistral': 2488, 'n_tokens_neox': 2378, 'n_words': 439}